Friday, 27 May 2011

SortedMap interface methods (java)

The SortedMap interface is used by TreeMap and adds additional methods to reflect that a TreeMap is sorted.
ResultMethodDescription
comp = comparator() Returns Comparator used to compare keys. null if natural ordering used (eg, String).
obj = firstKey() Key of first (in sorted order) element.
obj = lastKey() Key of last (in sorted order) element.
smp = headMap(obj) Returns SortedMap of all elements less than obj.
smp = tailMap(obj) Returns SortedMap of all elements greater than or equal to obj.
smp = subMap(fromKey, toKey) Returns SortedMap of all elements greater than or equal to fromKey and less than toKey.

No comments:

Post a Comment