Package org.djutils.immutablecollections
Interface ImmutableNavigableMap<K,V>
- Type Parameters:
K- the key type of content of this MapV- the value type of content of this Map
- All Superinterfaces:
ImmutableMap<K,V>,ImmutableSortedMap<K,V>,Serializable
- All Known Implementing Classes:
ImmutableTreeMap
public interface ImmutableNavigableMap<K,V> extends ImmutableSortedMap<K,V>
A
ImmutableSortedMap extended with navigation methods reporting closest matches for given search targets. Methods
lowerKey, floorKey, ceilingKey, and higherKey return 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. All methods
from java.util.NavigableMap that can change the map have been left out.
Copyright (c) 2016-2020 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.djutils.immutablecollections.ImmutableMap
ImmutableMap.ImmutableEntry<K,V> -
Method Summary
Modifier and Type Method Description KceilingKey(K e)Returns the least key in this immutable map greater than or equal to the given key, ornullif there is no such key.ImmutableNavigableMap<K,V>descendingMap()Returns a reverse order view of the keys contained in this immutable map.booleanequals(Object obj)Force to redefine equals for the implementations of immutable collection classes.KfloorKey(K e)Returns the greatest key in this immutable map less than or equal to the given key, ornullif there is no such key.inthashCode()Force to redefine hashCode for the implementations of immutable collection classes.ImmutableNavigableMap<K,V>headMap(K toKey, boolean inclusive)Returns a view of the portion of this immutable map whose keys are less than (or equal to, ifinclusiveis true)toKey.KhigherKey(K e)Returns the least key in this immutable map strictly greater than the given key, ornullif there is no such key.ImmutableSortedSet<K>keySet()Returns aImmutableSortedSetview of the keys contained in this map.KlowerKey(K e)Returns the greatest key in this immutable map strictly less than the given key, ornullif there is no such key.ImmutableNavigableMap<K,V>subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)Returns a view of the portion of this immutable map whose keys range fromfromKeytotoKey.ImmutableNavigableMap<K,V>tailMap(K fromKey, boolean inclusive)Returns a view of the portion of this immutable map whose keys are greater than (or equal to, ifinclusiveis true)fromKey.NavigableMap<K,V>toMap()Returns a modifiable copy of this immutable map.Methods inherited from interface org.djutils.immutablecollections.ImmutableMap
containsKey, containsValue, entrySet, forEach, get, getOrDefault, isCopy, isEmpty, isWrap, size, toString, valuesMethods inherited from interface org.djutils.immutablecollections.ImmutableSortedMap
comparator, firstKey, headMap, lastKey, subMap, tailMap
-
Method Details
-
toMap
NavigableMap<K,V> toMap()Returns a modifiable copy of this immutable map.- Specified by:
toMapin interfaceImmutableMap<K,V>- Specified by:
toMapin interfaceImmutableSortedMap<K,V>- Returns:
- a modifiable copy of this immutable map.
-
keySet
ImmutableSortedSet<K> keySet()Returns aImmutableSortedSetview of the keys contained in this map.- Specified by:
keySetin interfaceImmutableMap<K,V>- Specified by:
keySetin interfaceImmutableSortedMap<K,V>- Returns:
- an immutable sorted set of the keys contained in this map
-
lowerKey
Returns the greatest key in this immutable map strictly less than the given key, ornullif there is no such key.- Parameters:
e- K; the value to match- Returns:
- the greatest key less than
e, ornullif there is no such key - Throws:
ClassCastException- if the specified key cannot be compared with the keys currently in the immutable mapNullPointerException- if the specified key is null and this immutable map does not permit null keys
-
floorKey
Returns the greatest key in this immutable map less than or equal to the given key, ornullif there is no such key.- Parameters:
e- K; the value to match- Returns:
- the greatest key less than or equal to
e, ornullif there is no such key - Throws:
ClassCastException- if the specified key cannot be compared with the keys currently in the immutable mapNullPointerException- if the specified key is null and this immutable map does not permit null keys
-
ceilingKey
Returns the least key in this immutable map greater than or equal to the given key, ornullif there is no such key.- Parameters:
e- K; the value to match- Returns:
- the least key greater than or equal to
e, ornullif there is no such key - Throws:
ClassCastException- if the specified key cannot be compared with the keys currently in the immutable mapNullPointerException- if the specified key is null and this immutable map does not permit null keys
-
higherKey
Returns the least key in this immutable map strictly greater than the given key, ornullif there is no such key.- Parameters:
e- K; the value to match- Returns:
- the least key greater than
e, ornullif there is no such key - Throws:
ClassCastException- if the specified key cannot be compared with the keys currently in the immutable mapNullPointerException- if the specified key is null and this immutable map does not permit null keys
-
descendingMap
ImmutableNavigableMap<K,V> descendingMap()Returns a reverse order view of the keys contained in this immutable map.The returned immutable map has an ordering equivalent to
. The expressionCollections.reverseOrder(comparator())s.descendingMap().descendingMap()returns a view ofsessentially equivalent tos.- Returns:
- a reverse order view of this immutable map
-
subMap
Returns a view of the portion of this immutable map whose keys range fromfromKeytotoKey. IffromKeyandtoKeyare equal, the returned immutable map is empty unlessfromInclusiveandtoInclusiveare both true.- Parameters:
fromKey- K; low endpoint of the returned immutable mapfromInclusive- boolean;trueif the low endpoint is to be included in the returned viewtoKey- K; high endpoint of the returned immutable maptoInclusive- boolean;trueif the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable map whose keys range from
fromKey, inclusive, totoKey, exclusive - Throws:
ClassCastException- iffromKeyandtoKeycannot be compared to one another using this immutable map's comparator (or, if the immutable map has no comparator, using natural ordering). Implementations may, but are not required to, throw this exception iffromKeyortoKeycannot be compared to keys currently in the immutable map.NullPointerException- iffromKeyortoKeyis null and this immutable map does not permit null keysIllegalArgumentException- iffromKeyis greater thantoKey; or if this immutable map itself has a restricted range, andfromKeyortoKeylies outside the bounds of the range.
-
headMap
Returns a view of the portion of this immutable map whose keys are less than (or equal to, ifinclusiveis true)toKey.- Parameters:
toKey- K; high endpoint of the returned immutable mapinclusive- boolean;trueif the high endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable map whose keys are less than (or equal to, if
inclusiveis true)toKey - Throws:
ClassCastException- iftoKeyis not compatible with this immutable map's comparator (or, if the immutable map has no comparator, iftoKeydoes not implementComparable). Implementations may, but are not required to, throw this exception iftoKeycannot be compared to keys currently in the immutable map.NullPointerException- iftoKeyis null and this immutable map does not permit null keysIllegalArgumentException- if this immutable map itself has a restricted range, andtoKeylies outside the bounds of the range
-
tailMap
Returns a view of the portion of this immutable map whose keys are greater than (or equal to, ifinclusiveis true)fromKey.- Parameters:
fromKey- K; low endpoint of the returned immutable mapinclusive- boolean;trueif the low endpoint is to be included in the returned view- Returns:
- a view of the portion of this immutable map whose keys are greater than or equal to
fromKey - Throws:
ClassCastException- iffromKeyis not compatible with this immutable map's comparator (or, if the immutable map has no comparator, iffromKeydoes not implementComparable). Implementations may, but are not required to, throw this exception iffromKeycannot be compared to keys currently in the immutable map.NullPointerException- iffromKeyis null and this immutable map does not permit null keysIllegalArgumentException- if this immutable map itself has a restricted range, andfromKeylies outside the bounds of the range
-
equals
Force to redefine equals for the implementations of immutable collection classes.- Specified by:
equalsin interfaceImmutableMap<K,V>- Specified by:
equalsin interfaceImmutableSortedMap<K,V>- Overrides:
equalsin classObject- Parameters:
obj- Object; the object to compare this collection with- Returns:
- whether the objects are equal
-
hashCode
int hashCode()Force to redefine hashCode for the implementations of immutable collection classes.- Specified by:
hashCodein interfaceImmutableMap<K,V>- Specified by:
hashCodein interfaceImmutableSortedMap<K,V>- Overrides:
hashCodein classObject- Returns:
- the calculated hashCode
-