public interface NavigableMap<K, V>

ExtendsMap<K, V>, SortedMap<K, V>

Known subtypesTreeMap

NavigableMap is a SortedMap with navigation methods answering the closest matches for specified item.

Type parameter K: the type of key Type parameter V: the type of value

Methods

public abstract Map.Entry<K, V> firstEntry()Answers the entry with the smallest key, or null if the map is empty.
public abstract Map.Entry<K, V> lastEntry()Answers the entry with the biggest key, or null if the map is empty.
public abstract Map.Entry<K, V> pollFirstEntry()Deletes and answers the entry with the smallest key, or null if the map is empty.
public abstract Map.Entry<K, V> pollLastEntry()Deletes and answers the entry with the biggest key, or null if the map is empty.
public abstract Map.Entry<K, V> ceilingEntry(K key)Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.
public abstract K ceilingKey(K key)Answers the smallest key greater than or equal to the specified key, or null if no such key.
public abstract Map.Entry<K, V> higherEntry(K key)Answers an entry related with the smallest key greater than the specified key, or null if no such key.
public abstract K higherKey(K key)Answers the smallest key greater than the specified key, or null if no such key.
public abstract Map.Entry<K, V> floorEntry(K key)Answers an entry related with the biggest key less than or equal to the specified key, or null if no such key.
public abstract K floorKey(K key)Answers the biggest key less than or equal to the specified key, or null if no such key.
public abstract Map.Entry<K, V> lowerEntry(K key)Answers an entry related with the biggest key less than the specified key, or null if no such key.
public abstract K lowerKey(K key)Answers the biggest key less than the specified key, or null if no such key.
public abstract NavigableSet<K> navigableKeySet()Answers a NavigableSet view of the keys in ascending order.
public abstract NavigableMap<K, V> descendingMap()Answers a reverse order view of the map.
public abstract NavigableSet<K> descendingKeySet()Answers a NavigableSet view of the keys in descending order.
public abstract NavigableMap<K, V> subMap(K startKey, boolean startInclusive, K endKey, boolean endInclusive)Answers a view of part of the map whose keys is from startKey to endKey.
public abstract NavigableMap<K, V> headMap(K endKey, boolean inclusive)Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.
public abstract NavigableMap<K, V> tailMap(K startKey, boolean inclusive)Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.

Inherited nested types

Inherited methods

Method details

firstEntry

public abstract Map.Entry<K, V> firstEntry()
Answers the entry with the smallest key, or null if the map is empty.

Returns

the entry with the smallest key, or null if the map is empty

lastEntry

public abstract Map.Entry<K, V> lastEntry()
Answers the entry with the biggest key, or null if the map is empty.

Returns

the entry with the biggest key, or null if the map is empty

pollFirstEntry

public abstract Map.Entry<K, V> pollFirstEntry()
Deletes and answers the entry with the smallest key, or null if the map is empty.

Returns

the entry with the smallest key, or null if the map is empty

pollLastEntry

public abstract Map.Entry<K, V> pollLastEntry()
Deletes and answers the entry with the biggest key, or null if the map is empty.

Returns

the entry with the biggest key, or null if the map is empty

ceilingEntry

public abstract Map.Entry<K, V> ceilingEntry(K key)
Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.

Parameters

key K
the key

Returns

the entry, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

ceilingKey

public abstract K ceilingKey(K key)
Answers the smallest key greater than or equal to the specified key, or null if no such key.

Parameters

key K
the key

Returns

the smallest key greater than or equal to key, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

higherEntry

public abstract Map.Entry<K, V> higherEntry(K key)
Answers an entry related with the smallest key greater than the specified key, or null if no such key.

Parameters

key K
the key

Returns

the entry, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

higherKey

public abstract K higherKey(K key)
Answers the smallest key greater than the specified key, or null if no such key.

Parameters

key K
the key

Returns

the smallest key greater than key, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

floorEntry

public abstract Map.Entry<K, V> floorEntry(K key)
Answers an entry related with the biggest key less than or equal to the specified key, or null if no such key.

Parameters

key K
the key

Returns

the entry, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

floorKey

public abstract K floorKey(K key)
Answers the biggest key less than or equal to the specified key, or null if no such key.

Parameters

key K
the key

Returns

the biggest key less than or equal to key, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

lowerEntry

public abstract Map.Entry<K, V> lowerEntry(K key)
Answers an entry related with the biggest key less than the specified key, or null if no such key.

Parameters

key K
the key

Returns

the entry, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

lowerKey

public abstract K lowerKey(K key)
Answers the biggest key less than the specified key, or null if no such key.

Parameters

key K
the key

Returns

the biggest key less than key, or null if no such key

Throws

ClassCastException
if the key cannot be compared with the keys in the map
NullPointerException
if the key is null and the map can not contain null key

descendingMap

public abstract NavigableMap<K, V> descendingMap()
Answers a reverse order view of the map.

Returns

the reverse order view of the map

descendingKeySet

public abstract NavigableSet<K> descendingKeySet()
Answers a NavigableSet view of the keys in descending order.

Returns

the navigable set view

subMap

public abstract NavigableMap<K, V> subMap(K startKey, boolean startInclusive, K endKey, boolean endInclusive)
Answers a view of part of the map whose keys is from startKey to endKey.

Parameters

startKey K
the start key
startInclusive boolean
true if the start key is in the returned map
endKey K
the end key
endInclusive boolean
true if the end key is in the returned map

Returns

the sub-map view

Throws

ClassCastException
when the class of the start or end key is inappropriate for this SubMap
NullPointerException
when the start or end key is null and this SortedMap does not support null keys
IllegalArgumentException
when the start key is greater than the end key

headMap

public abstract NavigableMap<K, V> headMap(K endKey, boolean inclusive)
Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.

Parameters

endKey K
the end key
inclusive boolean
true if the end key is in the returned map

Returns

the head-map view

Throws

ClassCastException
when the class of the end key is inappropriate for this SubMap
NullPointerException
when the end key is null and this SortedMap does not support null keys
IllegalArgumentException
when the map is range-limited and end key is out of the range of the map

tailMap

public abstract NavigableMap<K, V> tailMap(K startKey, boolean inclusive)
Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.

Parameters

startKey K
the start key
inclusive boolean
true if the start key is in the returned map

Returns

the tail-map view

Throws

ClassCastException
when the class of the start key is inappropriate for this SubMap
NullPointerException
when the start key is null and this SortedMap does not support null keys
IllegalArgumentException
when the map is range-limited and start key is out of the range of the map