Sorted maps

Sorted maps

Post by Karsten Wu » Fri, 11 Apr 2008 13:54:55


I was trying to use a TreeMap to put values into that. I wonder how
such a map is sorted. How do I get the keys in a sorted manner? All I
found was to query a key set, but that isn't sorted. Is there any
(failry easy) way to achieve the above?


Sorted maps

Post by Roedy Gree » Fri, 11 Apr 2008 14:55:52

On Wed, 9 Apr 2008 21:54:55 -0700 (PDT), Karsten Wutzke
< XXXX@XXXXX.COM > wrote, quoted or indirectly quoted someone who said :


Roedy Green Canadian Mind Products
The Java Glossary


Sorted maps

Post by Boris Stum » Fri, 11 Apr 2008 17:27:35

rtfm ;-)

The SortedMap API documentation says:
This order is reflected when iterating over the sorted map's collection
views (returned by the entrySet, keySet and values methods).

And TreeMap implements SortedMap.