public interface SortedMap<K, V>
ExtendsMap<K, V>
Known subtypesNavigableMap, TreeMap
Methods
public abstract Comparator<? super K> comparator() | Returns the comparator used to compare keys in this sorted map. |
public abstract K firstKey() | Returns the first key in this sorted map. |
public abstract SortedMap<K, V> headMap(K endKey) | Returns a sorted map over a range of this sorted map with all keys that are less than the specified endKey. |
public abstract K lastKey() | Returns the last key in this sorted map. |
public abstract SortedMap<K, V> subMap(K startKey, K endKey) | Returns a sorted map over a range of this sorted map with all keys greater than or equal to the specified startKey and less than the specified endKey. |
public abstract SortedMap<K, V> tailMap(K startKey) | Returns a sorted map over a range of this sorted map with all keys that are greater than or equal to the specified startKey. |
Inherited nested types
Inherited methods
From Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values, getOrDefault, putIfAbsent, remove, replace, replace, forEach, replaceAll, computeIfAbsent, computeIfPresent, compute, merge
Method details
comparator
public abstract Comparator<? super K> comparator()Returns
null if the natural order is used.firstKey
public abstract K firstKey()Returns
Throws
NoSuchElementException- if this sorted map is empty.
headMap
public abstract SortedMap<K, V> headMap(K endKey)Returns a sorted map over a range of this sorted map with all keys that
are less than the specified endKey. Changes to the returned
sorted map are reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified range.
Parameters
endKeyK- the high boundary of the range specified.
Returns
endKey.Throws
ClassCastException- if the class of the end key is inappropriate for this sorted map.
NullPointerException- if the end key is
nulland this sorted map does not supportnullkeys. IllegalArgumentException- if this map is itself a sorted map over a range of another map and the specified key is outside of its range.
lastKey
public abstract K lastKey()Returns
Throws
NoSuchElementException- if this sorted map is empty.
subMap
public abstract SortedMap<K, V> subMap(K startKey, K endKey)Returns a sorted map over a range of this sorted map with all keys
greater than or equal to the specified startKey and less than the
specified endKey. Changes to the returned sorted map are
reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified range.
Parameters
startKeyK- the low boundary of the range (inclusive).
endKeyK- the high boundary of the range (exclusive),
Returns
Throws
ClassCastException- if the class of the start or end key is inappropriate for this sorted map.
NullPointerException- if the start or end key is
nulland this sorted map does not supportnullkeys. IllegalArgumentException- if the start key is greater than the end key, or if this map is itself a sorted map over a range of another sorted map and the specified range is outside of its range.
tailMap
public abstract SortedMap<K, V> tailMap(K startKey)Returns a sorted map over a range of this sorted map with all keys that
are greater than or equal to the specified startKey. Changes to
the returned sorted map are reflected in this sorted map and vice versa.
Note: The returned map will not allow an insertion of a key outside the specified range.
Parameters
startKeyK- the low boundary of the range specified.
Returns
startKey.Throws
ClassCastException- if the class of the start key is inappropriate for this sorted map.
NullPointerException- if the start key is
nulland this sorted map does not supportnullkeys. IllegalArgumentException- if this map itself a sorted map over a range of another map and the specified key is outside of its range.