Package org.djutils.immutablecollections
Class ImmutableTreeMap<K,V> 
java.lang.Object
org.djutils.immutablecollections.ImmutableAbstractMap<K,V>
 
org.djutils.immutablecollections.ImmutableTreeMap<K,V> 
- Type Parameters:
 K- the key type of content of this MapV- the value type of content of this Map
- All Implemented Interfaces:
 ImmutableMap<K,,V> ImmutableNavigableMap<K,,V> ImmutableSortedMap<K,V> 
public class ImmutableTreeMap<K,V> 
extends ImmutableAbstractMap<K,V>
implements ImmutableNavigableMap<K,V>  
An immutable wrapper for a TreeMap.
 
Copyright (c) 2016-2025 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
 
- 
Nested Class Summary
Nested classes/interfaces inherited from interface org.djutils.immutablecollections.ImmutableMap
ImmutableMap.ImmutableEntry<K,V>  - 
Field Summary
Fields inherited from class org.djutils.immutablecollections.ImmutableAbstractMap
cachedValues, copyOrWrap - 
Constructor Summary
ConstructorsConstructorDescriptionImmutableTreeMap(Map<K, V> sortedMap) ImmutableTreeMap(NavigableMap<K, V> map, Immutable copyOrWrap) ImmutableTreeMap(ImmutableAbstractMap<K, V> immutableMap) ImmutableTreeMap(ImmutableTreeMap<K, V> immutableTreeMap, Immutable copyOrWrap)  - 
Method Summary
Modifier and TypeMethodDescriptionfinal KceilingKey(K key) Returns the least key in this immutable map greater than or equal to the given key, ornullif there is no such key.final Comparator<? super K>Returns the comparator used to order the keys in this immutable map, ornullif this immutable map uses the natural ordering of its keys.final ImmutableNavigableMap<K,V> Returns a reverse order view of the keys contained in this immutable map.entrySet()Returns aSetview of the entries contained in this map.final KfirstKey()Returns the first (lowest) key currently in this immutable map.final KReturns the greatest key in this immutable map less than or equal to the given key, ornullif there is no such key.protected final NavigableMap<K,V> Return the raw underlying map.final ImmutableSortedMap<K,V> Returns a view of the portion of this immutable map whose keys are strictly less thantoKey.final ImmutableNavigableMap<K,V> Returns a view of the portion of this immutable map whose keys are less than (or equal to, ifinclusiveis true)toKey.final KReturns the least key in this immutable map strictly greater than the given key, ornullif there is no such key.final ImmutableSortedSet<K>keySet()Returns aImmutableSortedSetview of the keys contained in this map.final KlastKey()Returns the last (highest) key currently in this immutable map.final KReturns the greatest key in this immutable map strictly less than the given key, ornullif there is no such key.final ImmutableNavigableMap<K,V> Returns a view of the portion of this immutable map whose keys range fromfromKeytotoKey.final ImmutableSortedMap<K,V> Returns a view of the portion of this immutable map whose keys range fromfromKey, inclusive, totoKey, exclusive.final ImmutableSortedMap<K,V> Returns a view of the portion of this immutable map whose keys are greater than or equal tofromKey.final ImmutableNavigableMap<K,V> Returns a view of the portion of this immutable map whose keys are greater than (or equal to, ifinclusiveis true)fromKey.final NavigableMap<K,V> toMap()Returns a modifiable copy of this immutable map.final StringtoString()Force to redefine toString.values()Returns aImmutableCollectionview of the values contained in this map.Methods inherited from class org.djutils.immutablecollections.ImmutableAbstractMap
containsKey, containsValue, equals, get, hashCode, isEmpty, isWrap, sizeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.immutablecollections.ImmutableMap
containsKey, containsValue, forEach, get, getOrDefault, isCopy, isEmpty, isWrap, sizeMethods inherited from interface org.djutils.immutablecollections.ImmutableNavigableMap
equals, hashCode 
- 
Constructor Details
- 
ImmutableTreeMap
- Parameters:
 sortedMap- the map to use for the immutable map.
 - 
ImmutableTreeMap
- Parameters:
 immutableMap- the map to use for the immutable map.
 - 
ImmutableTreeMap
- Parameters:
 immutableTreeMap- the map to use for the immutable map.copyOrWrap- WRAP stores a pointer to the original collection
 
 - 
 - 
Method Details
- 
getUnderlyingMap
Description copied from class:ImmutableAbstractMapReturn the raw underlying map.- Overrides:
 getUnderlyingMapin classImmutableAbstractMap<K,V> - Returns:
 - the raw underlying map
 
 - 
toMap
Description copied from interface:ImmutableNavigableMapReturns a modifiable copy of this immutable map.- Specified by:
 toMapin interfaceImmutableMap<K,V> - Specified by:
 toMapin interfaceImmutableNavigableMap<K,V> - Specified by:
 toMapin interfaceImmutableSortedMap<K,V> - Returns:
 - a modifiable copy of this immutable map.
 
 - 
keySet
Description copied from interface:ImmutableNavigableMapReturns aImmutableSortedSetview of the keys contained in this map.- Specified by:
 keySetin interfaceImmutableMap<K,V> - Specified by:
 keySetin interfaceImmutableNavigableMap<K,V> - Specified by:
 keySetin interfaceImmutableSortedMap<K,V> - Returns:
 - an immutable sorted set of the keys contained in this map
 
 - 
entrySet
Description copied from interface:ImmutableMapReturns aSetview of the entries contained in this map.- Specified by:
 entrySetin interfaceImmutableMap<K,V> - Returns:
 - an immutable set of the entries contained in this map
 
 - 
values
Description copied from interface:ImmutableMapReturns aImmutableCollectionview of the values contained in this map.- Specified by:
 valuesin interfaceImmutableMap<K,V> - Overrides:
 valuesin classImmutableAbstractMap<K,V> - Returns:
 - an immutable collection view of the values contained in this map
 
 - 
comparator
Description copied from interface:ImmutableSortedMapReturns the comparator used to order the keys in this immutable map, ornullif this immutable map uses the natural ordering of its keys.- Specified by:
 comparatorin interfaceImmutableSortedMap<K,V> - Returns:
 - the comparator used to order the keys in this immutable map, or 
nullif this immutable map uses the natural ordering of its keys 
 - 
subMap
Description copied from interface:ImmutableSortedMapReturns a view of the portion of this immutable map whose keys range fromfromKey, inclusive, totoKey, exclusive. (IffromKeyandtoKeyare equal, the returned immutable map is empty.)The result of this method is a new, immutable sorted map.
- Specified by:
 subMapin interfaceImmutableSortedMap<K,V> - Parameters:
 fromKey- low endpoint (inclusive) of the returned immutable maptoKey- high endpoint (exclusive) of the returned immutable map- Returns:
 - a new, immutable sorted map of the portion of this immutable map whose keys range from 
fromKey, inclusive, totoKey, exclusive 
 - 
headMap
Description copied from interface:ImmutableSortedMapReturns a view of the portion of this immutable map whose keys are strictly less thantoKey. The returned immutable map is backed by this immutable map, so changes in the returned immutable map are reflected in this immutable map, and vice-versa. The returned immutable map supports all optional immutable map operations that this immutable map supports.The result of this method is a new, immutable sorted map.
- Specified by:
 headMapin interfaceImmutableSortedMap<K,V> - Parameters:
 toKey- high endpoint (exclusive) of the returned immutable map- Returns:
 - a view of the portion of this immutable map whose keys are strictly less than 
toKey 
 - 
tailMap
Description copied from interface:ImmutableSortedMapReturns a view of the portion of this immutable map whose keys are greater than or equal tofromKey. The returned immutable map is backed by this immutable map, so changes in the returned immutable map are reflected in this immutable map, and vice-versa. The returned immutable map supports all optional immutable map operations that this immutable map supports.The result of this method is a new, immutable sorted map.
- Specified by:
 tailMapin interfaceImmutableSortedMap<K,V> - Parameters:
 fromKey- low endpoint (inclusive) of the returned immutable map- Returns:
 - a view of the portion of this immutable map whose keys are greater than or equal to 
fromKey 
 - 
firstKey
Description copied from interface:ImmutableSortedMapReturns the first (lowest) key currently in this immutable map.- Specified by:
 firstKeyin interfaceImmutableSortedMap<K,V> - Returns:
 - the first (lowest) key currently in this immutable map
 
 - 
lastKey
Description copied from interface:ImmutableSortedMapReturns the last (highest) key currently in this immutable map.- Specified by:
 lastKeyin interfaceImmutableSortedMap<K,V> - Returns:
 - the last (highest) key currently in this immutable map
 
 - 
lowerKey
Description copied from interface:ImmutableNavigableMapReturns the greatest key in this immutable map strictly less than the given key, ornullif there is no such key.- Specified by:
 lowerKeyin interfaceImmutableNavigableMap<K,V> - Parameters:
 key- the value to match- Returns:
 - the greatest key less than 
e, ornullif there is no such key 
 - 
floorKey
Description copied from interface:ImmutableNavigableMapReturns the greatest key in this immutable map less than or equal to the given key, ornullif there is no such key.- Specified by:
 floorKeyin interfaceImmutableNavigableMap<K,V> - Parameters:
 key- the value to match- Returns:
 - the greatest key less than or equal to 
e, ornullif there is no such key 
 - 
ceilingKey
Description copied from interface:ImmutableNavigableMapReturns the least key in this immutable map greater than or equal to the given key, ornullif there is no such key.- Specified by:
 ceilingKeyin interfaceImmutableNavigableMap<K,V> - Parameters:
 key- the value to match- Returns:
 - the least key greater than or equal to 
e, ornullif there is no such key 
 - 
higherKey
Description copied from interface:ImmutableNavigableMapReturns the least key in this immutable map strictly greater than the given key, ornullif there is no such key.- Specified by:
 higherKeyin interfaceImmutableNavigableMap<K,V> - Parameters:
 key- the value to match- Returns:
 - the least key greater than 
e, ornullif there is no such key 
 - 
descendingMap
Description copied from interface:ImmutableNavigableMapReturns 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.- Specified by:
 descendingMapin interfaceImmutableNavigableMap<K,V> - Returns:
 - a reverse order view of this immutable map
 
 - 
subMap
public final ImmutableNavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive) Description copied from interface:ImmutableNavigableMapReturns a view of the portion of this immutable map whose keys range fromfromKeytotoKey. IffromKeyandtoKeyare equal, the returned immutable map is empty unlessfromInclusiveandtoInclusiveare both true.- Specified by:
 subMapin interfaceImmutableNavigableMap<K,V> - Parameters:
 fromKey- low endpoint of the returned immutable mapfromInclusive-trueif the low endpoint is to be included in the returned viewtoKey- high endpoint of the returned immutable maptoInclusive-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 
 - 
headMap
Description copied from interface:ImmutableNavigableMapReturns a view of the portion of this immutable map whose keys are less than (or equal to, ifinclusiveis true)toKey.- Specified by:
 headMapin interfaceImmutableNavigableMap<K,V> - Parameters:
 toKey- high endpoint of the returned immutable mapinclusive-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 
 - 
tailMap
Description copied from interface:ImmutableNavigableMapReturns a view of the portion of this immutable map whose keys are greater than (or equal to, ifinclusiveis true)fromKey.- Specified by:
 tailMapin interfaceImmutableNavigableMap<K,V> - Parameters:
 fromKey- low endpoint of the returned immutable mapinclusive-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 
 - 
toString
Description copied from interface:ImmutableMapForce to redefine toString. 
 -