SortedMap extended with navigation methods returning the
closest matches for given search targets. Methods
lowerEntry, floorEntry, ceilingEntry,
and higherEntry return Map.Entry objects
associated with keys respectively less than, less than or equal,
greater than or equal, and greater than a given key, returning
null if there is no such key. Similarly, methods
lowerKey, floorKey, ceilingKey, and
higherKey return only the associated keys. All of these
methods are designed for locating, not traversing entries.
A NavigableMap may be accessed and traversed in either
ascending or descending key order. The descendingMap
method returns a view of the map with the senses of all relational
and directional methods inverted. The performance of ascending
operations and views is likely to be faster than that of descending
ones. Methods
subMap(K, boolean, K, boolean),
headMap(K, boolean), and
tailMap(K, boolean)
differ from the like-named SortedMap methods in accepting
additional arguments describing whether lower and upper bounds are
inclusive versus exclusive. Submaps of any NavigableMap
must implement the NavigableMap interface.
This interface additionally defines methods firstEntry,
pollFirstEntry, lastEntry, and
pollLastEntry that return and/or remove the least and
greatest mappings, if any exist, else returning null.
The methods
ceilingEntry,
firstEntry,
floorEntry,
higherEntry,
lastEntry,
lowerEntry,
pollFirstEntry, and
pollLastEntry
return Map. instances that represent snapshots of mappings as
of the time of the call. They do not support mutation of the
underlying map via the optional setValue method.
Methods
subMap(K, K),
headMap(K), and
tailMap(K)
are specified to return SortedMap to allow existing
implementations of SortedMap to be compatibly retrofitted to
implement NavigableMap, but extensions and implementations
of this interface are encouraged to override these methods to return
NavigableMap. Similarly,
keySet() can be overridden to return NavigableSet.
This interface is a member of the Java Collections Framework.
| Modifier and Type | Method and Description |
|---|---|
| public Map. | Returns: an entry with the least key greater than or equal tokey, or null if there is no such keythe key key)Returns a key-value mapping associated with the least key
greater than or equal to the given key, or |
| public K | Returns: the least key greater than or equal tokey,
or null if there is no such keythe key key)Returns the least key greater than or equal to the given key,
or |
| public NavigableSet | Returns: a reverse order navigable set view of the keys in this mapReturns a reverse order |
| public NavigableMap | Returns: a reverse order view of this mapReturns a reverse order view of the mappings contained in this map. |
| public Map. | Returns: an entry with the least key, ornull if this map is emptyRedeclares as abstract: java. Returns a key-value mapping associated with the least
key in this map, or |
| public Map. | Returns: an entry with the greatest key less than or equal tokey, or null if there is no such keythe key key)Returns a key-value mapping associated with the greatest key
less than or equal to the given key, or |
| public K | Returns: the greatest key less than or equal tokey,
or null if there is no such keythe key key)Returns the greatest key less than or equal to the given key,
or |
| public NavigableMap | Returns: a view of the portion of this map whose keys are less than (or equal to, ifinclusive is true) toKeyhigh endpoint of the keys in the returned map toKey, boolean true if the high endpoint
is to be included in the returned viewReturns a view of the portion of this map whose keys are less than (or
equal to, if |
| public SortedMap | headMap(K toKey)
Redeclares java. Returns a view of the portion of this map whose keys are
strictly less than |
| public Map. | Returns: an entry with the least key greater thankey,
or null if there is no such keythe key key)Returns a key-value mapping associated with the least key
strictly greater than the given key, or |
| public K | Returns: the least key greater thankey,
or null if there is no such keythe key key)Returns the least key strictly greater than the given key, or
|
| public Map. | Returns: an entry with the greatest key, ornull if this map is emptyRedeclares as abstract: java. Returns a key-value mapping associated with the greatest
key in this map, or |
| public Map. | Returns: an entry with the greatest key less thankey,
or null if there is no such keythe key key)Returns a key-value mapping associated with the greatest key
strictly less than the given key, or |
| public K | Returns: the greatest key less thankey,
or null if there is no such keythe key key)Returns the greatest key strictly less than the given key, or
|
| public NavigableSet | Returns: a navigable set view of the keys in this mapReturns a |
| public Map. | Returns: the removed first entry of this map, ornull if this map is emptyRedeclares as abstract: java. Removes and returns a key-value mapping associated with
the least key in this map, or |
| public Map. | Returns: the removed last entry of this map, ornull if this map is emptyRedeclares as abstract: java. Removes and returns a key-value mapping associated with
the greatest key in this map, or |
| public default NavigableMap | Returns: a reverse-ordered view of this map, as aNavigableMapOverrides default java. Returns a reverse-ordered view of this map. |
| public NavigableMap | Returns: a view of the portion of this map whose keys range fromfromKey to toKeylow endpoint of the keys in the returned map fromKey, boolean true if the low endpoint
is to be included in the returned viewhigh endpoint of the keys in the returned map toKey, boolean true if the high endpoint
is to be included in the returned viewReturns a view of the portion of this map whose keys range from
|
| public SortedMap | subMap(K fromKey, K toKey)
Redeclares java. Returns a view of the portion of this map whose keys range from
|
| public NavigableMap | Returns: a view of the portion of this map whose keys are greater than (or equal to, ifinclusive is true) fromKeylow endpoint of the keys in the returned map fromKey, boolean true if the low endpoint
is to be included in the returned viewReturns a view of the portion of this map whose keys are greater than (or
equal to, if |
| public SortedMap | tailMap(K fromKey)
Redeclares java. Returns a view of the portion of this map whose keys are
greater than or equal to |
| ceilingEntry | back to summary |
|---|---|
| public Map. Returns a key-value mapping associated with the least key
greater than or equal to the given key, or
| |
| ceilingKey | back to summary |
|---|---|
| public K ceilingKey(K key) Returns the least key greater than or equal to the given key,
or
| |
| descendingKeySet | back to summary |
|---|---|
| public NavigableSet Returns a reverse order
| |
| descendingMap | back to summary |
|---|---|
| public NavigableMap Returns a reverse order view of the mappings contained in this map.
The descending map is backed by this map, so changes to the map are
reflected in the descending map, and vice-versa. If either map is
modified while an iteration over a collection view of either map
is in progress (except through the iterator's own The returned map has an ordering equivalent to
| |
| firstEntry | back to summary |
|---|---|
| public Map. Redeclares as abstract: java. Returns a key-value mapping associated with the least
key in this map, or | |
| floorEntry | back to summary |
|---|---|
| public Map. Returns a key-value mapping associated with the greatest key
less than or equal to the given key, or
| |
| floorKey | back to summary |
|---|---|
| public K floorKey(K key) Returns the greatest key less than or equal to the given key,
or
| |
| headMap | back to summary |
|---|---|
| public NavigableMap Returns a view of the portion of this map whose keys are less than (or
equal to, if The returned map will throw an
| |
| headMap | back to summary |
|---|---|
| public SortedMap Redeclares java. Doc from java. Returns a view of the portion of this map whose keys are
strictly less than The returned map will throw an Equivalent to
| |
| higherEntry | back to summary |
|---|---|
| public Map. Returns a key-value mapping associated with the least key
strictly greater than the given key, or
| |
| higherKey | back to summary |
|---|---|
| public K higherKey(K key) Returns the least key strictly greater than the given key, or
| |
| lastEntry | back to summary |
|---|---|
| public Map. Redeclares as abstract: java. Returns a key-value mapping associated with the greatest
key in this map, or | |
| lowerEntry | back to summary |
|---|---|
| public Map. Returns a key-value mapping associated with the greatest key
strictly less than the given key, or
| |
| lowerKey | back to summary |
|---|---|
| public K lowerKey(K key) Returns the greatest key strictly less than the given key, or
| |
| navigableKeySet | back to summary |
|---|---|
| public NavigableSet Returns a
| |
| pollFirstEntry | back to summary |
|---|---|
| public Map. Redeclares as abstract: java. Removes and returns a key-value mapping associated with
the least key in this map, or
| |
| pollLastEntry | back to summary |
|---|---|
| public Map. Redeclares as abstract: java. Removes and returns a key-value mapping associated with
the greatest key in this map, or
| |
| reversed | back to summary |
|---|---|
| public default NavigableMap Overrides default java. Doc from java. Returns a reverse-ordered view of this map. The encounter order of mappings in the returned view is the inverse of the encounter order of mappings in this map. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view. If the implementation permits modifications to this view, the modifications "write through" to the underlying map. Changes to the underlying map might or might not be visible in this reversed view, depending upon the implementation.
This method is equivalent to Implementation Specification The implementation in this interface returns the result of calling the
| |
| subMap | back to summary |
|---|---|
| public NavigableMap Returns a view of the portion of this map whose keys range from
The returned map will throw an
| |
| subMap | back to summary |
|---|---|
| public SortedMap Redeclares java. Doc from java. Returns a view of the portion of this map whose keys range from
The returned map will throw an Equivalent to
| |
| tailMap | back to summary |
|---|---|
| public NavigableMap Returns a view of the portion of this map whose keys are greater than (or
equal to, if The returned map will throw an
| |
| tailMap | back to summary |
|---|---|
| public SortedMap Redeclares java. Doc from java. Returns a view of the portion of this map whose keys are
greater than or equal to The returned map will throw an Equivalent to
| |