Java Reference
In-Depth Information
TreeMap is an example of a sorted map, which is a map that maintains its entries in
ascending order, sorted according to the keys' natural ordering or according to a com-
parator that is supplied when the sorted map is created. Sorted maps are described by
the SortedMap interface.
SortedMap , whose generic type is SortedMap<K,V> , extends Map . With two
exceptions, the methods it inherits from Map behave identically on sorted maps as on
other maps:
• The Iterator instancereturnedbythe iterator() methodonanyofthe
sorted map's Collection views traverses the collections in order.
• Thearraysreturnedbythe Collection views' toArray() methodscontain
the keys, values, or entries in order.
Note Although not guaranteed, the toString() methods of the Collection
views of SortedSet implementations in the Collections Framework (such as
TreeMap ) return a string containing all of the view's elements in order.
SortedMap 'sdocumentationrequiresthatanimplementationmustprovidethefour
standardconstructorsthatIpresentedinmydiscussionof TreeMap .Furthermore,im-
plementationsofthisinterfacemustimplementthemethodsthataredescribedin Table
5-10 .
Search WWH ::

Custom Search