Interface NavigableMap<K,V>
- Type Parameters:
K- the type of keyV- the type of value
- All Known Implementing Classes:
TreeMap
NavigableMap is a SortedMap with navigation methods answering the closest
matches for specified item.
- Since:
- 1.6
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionceilingEntry(K key) Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.ceilingKey(K key) Answers the smallest key greater than or equal to the specified key, or null if no such key.Answers a NavigableSet view of the keys in descending order.Answers a reverse order view of the map.Answers the entry with the smallest key, or null if the map is empty.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.Answers the biggest key less than or equal to the specified key, or null if no such key.Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.higherEntry(K key) Answers an entry related with the smallest key greater than the specified key, or null if no such key.Answers the smallest key greater than the specified key, or null if no such key.Answers the entry with the biggest key, or null if the map is empty.lowerEntry(K key) Answers an entry related with the biggest key less than the specified key, or null if no such key.Answers the biggest key less than the specified key, or null if no such key.Answers a NavigableSet view of the keys in ascending order.Deletes and answers the entry with the smallest key, or null if the map is empty.Deletes and answers the entry with the biggest key, or null if the map is empty.Answers a view of part of the map whose keys is from startKey to endKey.Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.Methods inherited from interface Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, valuesModifier and TypeMethodDescriptionvoidclear()Removes all elements from thisMap, leaving it empty.booleancontainsKey(Object key) Returns whether thisMapcontains the specified key.booleancontainsValue(Object value) Returns whether thisMapcontains the specified value.entrySet()Returns aSetcontaining all of the mappings in thisMap.booleanCompares the argument to the receiver, and returnstrueif the specified object is aMapand bothMaps contain the same mappings.Returns the value of the mapping with the specified key.inthashCode()Returns an integer hash code for the receiver.booleanisEmpty()Returns whether this map is empty.keySet()Returns a set of the keys contained in thisMap.Maps the specified key to the specified value.voidCopies every mapping in the specifiedMapto thisMap.Removes a mapping with the specified key from thisMap.intsize()Returns the number of mappings in thisMap.values()Returns aCollectionof the values contained in thisMap.Methods inherited from interface SortedMap
comparator, firstKey, headMap, lastKey, subMap, tailMapModifier and TypeMethodDescriptionComparator<? super K> Returns the comparator used to compare keys in this sorted map.firstKey()Returns the first key in this sorted map.Returns a sorted map over a range of this sorted map with all keys that are less than the specifiedendKey.lastKey()Returns the last key in this sorted map.Returns a sorted map over a range of this sorted map with all keys greater than or equal to the specifiedstartKeyand less than the specifiedendKey.Returns a sorted map over a range of this sorted map with all keys that are greater than or equal to the specifiedstartKey.
-
Method Details
-
firstEntry
-
lastEntry
-
pollFirstEntry
-
pollLastEntry
-
ceilingEntry
Answers an entry related with the smallest key greater than or equal to the specified key, or null if no such key.- Parameters:
key- the key- Returns:
- the entry, or null if no such key
- Throws:
ClassCastException- if the key cannot be compared with the keys in the mapNullPointerException- if the key is null and the map can not contain null key
-
ceilingKey
Answers the smallest key greater than or equal to the specified key, or null if no such key.- Parameters:
key- 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 mapNullPointerException- if the key is null and the map can not contain null key
-
higherEntry
Answers an entry related with the smallest key greater than the specified key, or null if no such key.- Parameters:
key- the key- Returns:
- the entry, or null if no such key
- Throws:
ClassCastException- if the key cannot be compared with the keys in the mapNullPointerException- if the key is null and the map can not contain null key
-
higherKey
Answers the smallest key greater than the specified key, or null if no such key.- Parameters:
key- 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 mapNullPointerException- if the key is null and the map can not contain null key
-
floorEntry
Answers an entry related with the biggest key less than or equal to the specified key, or null if no such key.- Parameters:
key- the key- Returns:
- the entry, or null if no such key
- Throws:
ClassCastException- if the key cannot be compared with the keys in the mapNullPointerException- if the key is null and the map can not contain null key
-
floorKey
Answers the biggest key less than or equal to the specified key, or null if no such key.- Parameters:
key- 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 mapNullPointerException- if the key is null and the map can not contain null key
-
lowerEntry
Answers an entry related with the biggest key less than the specified key, or null if no such key.- Parameters:
key- the key- Returns:
- the entry, or null if no such key
- Throws:
ClassCastException- if the key cannot be compared with the keys in the mapNullPointerException- if the key is null and the map can not contain null key
-
lowerKey
Answers the biggest key less than the specified key, or null if no such key.- Parameters:
key- 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 mapNullPointerException- if the key is null and the map can not contain null key
-
descendingMap
NavigableMap<K,V> descendingMap()Answers a reverse order view of the map.- Returns:
- the reverse order view of the map
-
descendingKeySet
NavigableSet<K> descendingKeySet()Answers a NavigableSet view of the keys in descending order.- Returns:
- the navigable set view
-
subMap
Answers a view of part of the map whose keys is from startKey to endKey.- Parameters:
startKey- the start keystartInclusive- true if the start key is in the returned mapendKey- the end keyendInclusive- 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 SubMapNullPointerException- when the start or end key is null and this SortedMap does not support null keysIllegalArgumentException- when the start key is greater than the end key
-
headMap
Answers a view of the head of the map whose keys are smaller than (or equal to, depends on inclusive argument) endKey.- Parameters:
endKey- the end keyinclusive- 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 SubMapNullPointerException- when the end key is null and this SortedMap does not support null keysIllegalArgumentException- when the map is range-limited and end key is out of the range of the map
-
tailMap
Answers a view of the tail of the map whose keys are bigger than (or equal to, depends on inclusive argument) startKey.- Parameters:
startKey- the start keyinclusive- 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 SubMapNullPointerException- when the start key is null and this SortedMap does not support null keysIllegalArgumentException- when the map is range-limited and start key is out of the range of the map
-