<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Remove duplicates</title>
	<atom:link href="http://blog.refactor.se/2006/07/31/remove-duplicates/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.refactor.se/2006/07/31/remove-duplicates/</link>
	<description>Thoughts on Java, Agile, OS X and life in general..</description>
	<lastBuildDate>Fri, 09 Apr 2010 08:35:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stephen Colebourne</title>
		<link>http://blog.refactor.se/2006/07/31/remove-duplicates/comment-page-1/#comment-23</link>
		<dc:creator>Stephen Colebourne</dc:creator>
		<pubDate>Tue, 01 Aug 2006 02:05:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.refactor.se/2006/07/31/remove-duplicates/#comment-23</guid>
		<description>Just be aware that this method does create a lot of objects behind the scenes. A LinkedHashSet uses a LinkedHashMap, which creates one entry (object) for every item added. Clearly these all need to be created and garbage collected. Depending on your setup that may be important. (Normally though, I would advise not worrying too much about object creation and gc ;-) But for a smaller list it may be quicker to deduplicate without the Set.</description>
		<content:encoded><![CDATA[<p>Just be aware that this method does create a lot of objects behind the scenes. A LinkedHashSet uses a LinkedHashMap, which creates one entry (object) for every item added. Clearly these all need to be created and garbage collected. Depending on your setup that may be important. (Normally though, I would advise not worrying too much about object creation and gc <img src='http://blog.refactor.se/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  But for a smaller list it may be quicker to deduplicate without the Set.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian</title>
		<link>http://blog.refactor.se/2006/07/31/remove-duplicates/comment-page-1/#comment-22</link>
		<dc:creator>Brian</dc:creator>
		<pubDate>Mon, 31 Jul 2006 22:51:32 +0000</pubDate>
		<guid isPermaLink="false">http://blog.refactor.se/2006/07/31/remove-duplicates/#comment-22</guid>
		<description>You might be better off with the following....

public void removeDuplicates(List items) {
Set set = new LinkedHashSet();
set.addAll(items);
items.removeAll();
items.addAll(set);
}

This way you&#039;ll still have the same object reference that you started with instead of a completely new list.</description>
		<content:encoded><![CDATA[<p>You might be better off with the following&#8230;.</p>
<p>public void removeDuplicates(List items) {<br />
Set set = new LinkedHashSet();<br />
set.addAll(items);<br />
items.removeAll();<br />
items.addAll(set);<br />
}</p>
<p>This way you&#8217;ll still have the same object reference that you started with instead of a completely new list.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
