<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Java maps and sorting</title>
	<atom:link href="http://mendicantbug.com/2009/08/01/java-maps-and-sorting/feed/" rel="self" type="application/rss+xml" />
	<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/</link>
	<description>Wanderings into computational linguistics, science, social media and life...</description>
	<lastBuildDate>Mon, 23 Apr 2012 02:02:52 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Umm, TreeMap?</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-2427</link>
		<dc:creator><![CDATA[Umm, TreeMap?]]></dc:creator>
		<pubDate>Wed, 24 Mar 2010 02:02:16 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-2427</guid>
		<description><![CDATA[What about TreeMap - its been around since almost forever?

A map that further guarantees that it will be in ascending key order, sorted according to the natural ordering of its keys (see the Comparable interface), or by a comparator provided at sorted map creation time. This order is reflected when iterating over the sorted map&#039;s collection views (returned by the entrySet, keySet  and values methods). Several additional operations are provided to take advantage of the ordering. (This interface is the map analogue of the SortedSet interface.)]]></description>
		<content:encoded><![CDATA[<p>What about TreeMap &#8211; its been around since almost forever?</p>
<p>A map that further guarantees that it will be in ascending key order, sorted according to the natural ordering of its keys (see the Comparable interface), or by a comparator provided at sorted map creation time. This order is reflected when iterating over the sorted map&#8217;s collection views (returned by the entrySet, keySet  and values methods). Several additional operations are provided to take advantage of the ordering. (This interface is the map analogue of the SortedSet interface.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jhumphries</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-1881</link>
		<dc:creator><![CDATA[jhumphries]]></dc:creator>
		<pubDate>Sat, 08 Aug 2009 23:38:30 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-1881</guid>
		<description><![CDATA[You can get around the O(n log n) get()&#039;s by using the map&#039;s entrySet() - instead of keySet(). The comparator then has access to both values w/out having to do a look-up in the map. Of course, this means you&#039;d be returning the sorted set of entries, not just the sorted set of keys.]]></description>
		<content:encoded><![CDATA[<p>You can get around the O(n log n) get()&#8217;s by using the map&#8217;s entrySet() &#8211; instead of keySet(). The comparator then has access to both values w/out having to do a look-up in the map. Of course, this means you&#8217;d be returning the sorted set of entries, not just the sorted set of keys.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Adams</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-1833</link>
		<dc:creator><![CDATA[Jason Adams]]></dc:creator>
		<pubDate>Sun, 02 Aug 2009 13:22:10 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-1833</guid>
		<description><![CDATA[Good point.  For this particular application, I&#039;m just using wrappers for primitives (Integers and Doubles), so I&#039;m assuming the hashCode calculation is fast.  Also, the dataset is in the &lt; 200k entries range so the sorting time is pretty much negligible.  Still, I should be thinking of bigger data, if I&#039;m wanting a general purpose sort-by-values algorithm.]]></description>
		<content:encoded><![CDATA[<p>Good point.  For this particular application, I&#8217;m just using wrappers for primitives (Integers and Doubles), so I&#8217;m assuming the hashCode calculation is fast.  Also, the dataset is in the &lt; 200k entries range so the sorting time is pretty much negligible.  Still, I should be thinking of bigger data, if I&#039;m wanting a general purpose sort-by-values algorithm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Adams</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-1831</link>
		<dc:creator><![CDATA[Jason Adams]]></dc:creator>
		<pubDate>Sun, 02 Aug 2009 13:09:22 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-1831</guid>
		<description><![CDATA[Thanks for the tip on Apache Commons.  SortedBidiMap is probably more than I need for this, but glad to know it exists.]]></description>
		<content:encoded><![CDATA[<p>Thanks for the tip on Apache Commons.  SortedBidiMap is probably more than I need for this, but glad to know it exists.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon Elsas</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-1829</link>
		<dc:creator><![CDATA[Jon Elsas]]></dc:creator>
		<pubDate>Sun, 02 Aug 2009 11:58:01 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-1829</guid>
		<description><![CDATA[you&#039;re doing O(n log n) get()&#039;s which isn&#039;t a big deal if your key&#039;s hashCode() is fast, but might be slow in some cases.  Depending on what you&#039;re storing, I would consider sorting a list of Map.Entry, then extract the keys post-sort.  This would require zero calls to hashCode().]]></description>
		<content:encoded><![CDATA[<p>you&#8217;re doing O(n log n) get()&#8217;s which isn&#8217;t a big deal if your key&#8217;s hashCode() is fast, but might be slow in some cases.  Depending on what you&#8217;re storing, I would consider sorting a list of Map.Entry, then extract the keys post-sort.  This would require zero calls to hashCode().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DrNI@AM</title>
		<link>http://mendicantbug.com/2009/08/01/java-maps-and-sorting/#comment-1828</link>
		<dc:creator><![CDATA[DrNI@AM]]></dc:creator>
		<pubDate>Sun, 02 Aug 2009 08:46:20 +0000</pubDate>
		<guid isPermaLink="false">http://mendicantbug.com/?p=1250#comment-1828</guid>
		<description><![CDATA[Looks the way I would have done it. It&#039;s perfectly logical that there is no such service for a HashMap because it is unsorted by definition.

Did you have a look at Apache Commons? Not only do they have a useful box of convenience classes and methods for Strings, they also have a similar thing for collections: http://commons.apache.org/collections/ - their SortedBidiMap looks fancy.]]></description>
		<content:encoded><![CDATA[<p>Looks the way I would have done it. It&#8217;s perfectly logical that there is no such service for a HashMap because it is unsorted by definition.</p>
<p>Did you have a look at Apache Commons? Not only do they have a useful box of convenience classes and methods for Strings, they also have a similar thing for collections: <a href="http://commons.apache.org/collections/" rel="nofollow">http://commons.apache.org/collections/</a> &#8211; their SortedBidiMap looks fancy.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

