img
Method
Description
Comparator<? super K> comparator( )
Returns the invoking sor ted map's comparator. If natural
ordering is used for the invoking map, null is returned.
K firstKey( )
Returns the first key in the invoking map.
Sor tedMap<K, V> headMap(K end)
Returns a sor ted map for those map entries with keys that are
less than end.
K lastKey( )
Returns the last key in the invoking map.
Sor tedMap<K, V> subMap(K star t, K end)
Returns a map containing those entries with keys that are
greater than or equal to star t and less than end.
Sor tedMap<K, V> tailMap(K star t)
Returns a map containing those entries with keys that are
greater than or equal to star t.
TABLE 17-11
The Methods Defined by SortedMap
The NavigableMap Interface
The NavigableMap interface was added by Java SE 6. It extends SortedMap and declares
the behavior of a map that supports the retrieval of entries based on the closest match to a
given key or keys. NavigableMap is a generic interface that has this declaration:
interface NavigableMap<K,V>
Here, K specifies the type of the keys, and V specifies the type of the values associated with
the keys. In addition to the methods that it inherits from SortedMap, NavigableMap adds
those summarized in Table 17-12. Several methods throw a ClassCastException when
an object is incompatible with the keys in the map. A NullPointerException is thrown
if an attempt is made to use a null object and null keys are not allowed in the set. An
IllegalArgumentException is thrown if an invalid argument is used.
Method
Description
Map.Entr y<K,V> ceilingEntr y(K obj)
Searches the map for the smallest key k such that k >= obj. If such a key
is found, its entr y is returned. Other wise, null is returned.
K ceilingKey(K obj)
Searches the map for the smallest key k such that k >= obj. If such a key
is found, it is returned. Other wise, null is returned.
NavigableSet<K> descendingKeySet( )
Returns a NavigableSet that contains the keys in the invoking map in
reverse order. Thus, it returns a reverse set-view of the keys. The
resulting set is backed by the map.
NavigableMap<K,V> descendingMap( )
Returns a NavigableMap that is the reverse of the invoking map. The
resulting map is backed by the invoking map.
Map.Entr y<K,V> firstEntr y( )
Returns the first entr y in the map. This is the entr y with the least key.
Map.Entr y<K,V> floorEntr y(K obj)
Searches the map for the largest key k such that k <= obj. If such a key
is found, its entr y is returned. Other wise, null is returned.
K floorKey(K obj)
Searches the map for the largest key k such that k <= obj. If such a key
is found, it is returned. Other wise, null is returned.
Returns a NavigableMap that includes all entries from the invoking map
NavigableMap<K,V>
headMap(K upperBound, boolean incl)
that have keys that are less than upperBound. If incl is true, then an
element equal to upperBound is included. The resulting map is backed by
the invoking map.
Map.Entr y<K,V> higherEntr y(K obj)
Searches the set for the largest key k such that k > obj. If such a key is
found, its entr y is returned. Other wise, null is returned.
TABLE 17-12
The Methods defined by NavigableMap
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home