K
- the key type of content of this MapV
- the value type of content of this Mappublic class ImmutableTreeMap<K,V> extends ImmutableAbstractMap<K,V> implements ImmutableNavigableMap<K,V>
Copyright (c) 2013-2016 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
Constructor and Description |
---|
ImmutableTreeMap(ImmutableTreeMap<K,V> immutableMap) |
ImmutableTreeMap(ImmutableTreeMap<K,V> immutableTreeMap,
Immutable copyOrWrap) |
ImmutableTreeMap(SortedMap<K,V> sortedMap) |
ImmutableTreeMap(SortedMap<K,V> map,
Immutable copyOrWrap) |
Modifier and Type | Method and Description |
---|---|
K |
ceilingKey(K key)
Returns the least key in this immutable map greater than or equal to the given key, or
null if there is no such
key. |
Comparator<? super K> |
comparator()
Returns the comparator used to order the keys in this immutable map, or null if this immutable map uses the
natural ordering of its keys.
|
ImmutableNavigableMap<K,V> |
descendingMap()
Returns a reverse order view of the keys contained in this immutable map.
|
K |
firstKey()
Returns the first (lowest) key currently in this immutable map.
|
K |
floorKey(K key)
Returns the greatest key in this immutable map less than or equal to the given key, or
null if there is no such
key. |
protected NavigableMap<K,V> |
getMap()
Prepare the map of the right type for use a subclass.
|
ImmutableSortedMap<K,V> |
headMap(K toKey)
Returns a view of the portion of this immutable map whose keys are strictly less than toKey.
|
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, if
inclusive is true)
toKey . |
K |
higherKey(K key)
Returns the least key in this immutable map strictly greater than the given key, or
null if there is no such key. |
ImmutableSortedSet<K> |
keySet()
Returns a
ImmutableSortedSet view of the keys contained in this map. |
K |
lastKey()
Returns the last (highest) key currently in this immutable map.
|
K |
lowerKey(K key)
Returns the greatest key in this immutable map strictly less than the given key, or
null if 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 from
fromKey to toKey . |
ImmutableSortedMap<K,V> |
subMap(K fromKey,
K toKey)
Returns a view of the portion of this immutable map whose keys range from fromKey, inclusive, to
toKey, exclusive.
|
ImmutableSortedMap<K,V> |
tailMap(K fromKey)
Returns a view of the portion of this immutable map whose keys are greater than or equal to fromKey.
|
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, if
inclusive is
true) fromKey . |
NavigableMap<K,V> |
toMap()
Returns a modifiable copy of this immutable map.
|
String |
toString() |
containsKey, containsValue, equals, get, hashCode, isEmpty, isWrap, size, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
equals, hashCode
containsKey, containsValue, forEach, get, getOrDefault, isCopy, isEmpty, isWrap, size, values
public ImmutableTreeMap(SortedMap<K,V> sortedMap)
sortedMap
- the map to use as the immutable map.public ImmutableTreeMap(SortedMap<K,V> map, Immutable copyOrWrap)
map
- the map to use as the immutable map.copyOrWrap
- COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionpublic ImmutableTreeMap(ImmutableTreeMap<K,V> immutableMap)
immutableMap
- the map to use as the immutable map.public ImmutableTreeMap(ImmutableTreeMap<K,V> immutableTreeMap, Immutable copyOrWrap)
immutableTreeMap
- the map to use as the immutable map.copyOrWrap
- COPY stores a safe, internal copy of the collection; WRAP stores a pointer to the original collectionprotected final NavigableMap<K,V> getMap()
@Override protected HashMap<E> getMap() { return (HashMap<E>) super.getMap(); }
getMap
in class ImmutableAbstractMap<K,V>
public final NavigableMap<K,V> toMap()
toMap
in interface ImmutableMap<K,V>
toMap
in interface ImmutableNavigableMap<K,V>
toMap
in interface ImmutableSortedMap<K,V>
public final ImmutableSortedSet<K> keySet()
ImmutableSortedSet
view of the keys contained in this map.keySet
in interface ImmutableMap<K,V>
keySet
in interface ImmutableNavigableMap<K,V>
keySet
in interface ImmutableSortedMap<K,V>
public final Comparator<? super K> comparator()
comparator
in interface ImmutableSortedMap<K,V>
public final ImmutableSortedMap<K,V> subMap(K fromKey, K toKey)
The result of this method is a new, immutable sorted map.
subMap
in interface ImmutableSortedMap<K,V>
fromKey
- low endpoint (inclusive) of the returned immutable maptoKey
- high endpoint (exclusive) of the returned immutable mappublic final ImmutableSortedMap<K,V> headMap(K toKey)
The result of this method is a new, immutable sorted map.
headMap
in interface ImmutableSortedMap<K,V>
toKey
- high endpoint (exclusive) of the returned immutable mappublic final ImmutableSortedMap<K,V> tailMap(K fromKey)
The result of this method is a new, immutable sorted map.
tailMap
in interface ImmutableSortedMap<K,V>
fromKey
- low endpoint (inclusive) of the returned immutable mappublic final K firstKey()
firstKey
in interface ImmutableSortedMap<K,V>
public final K lastKey()
lastKey
in interface ImmutableSortedMap<K,V>
public final K lowerKey(K key)
null
if there is no such key.lowerKey
in interface ImmutableNavigableMap<K,V>
key
- the value to matche
, or null
if there is no such keypublic final K floorKey(K key)
null
if there is no such
key.floorKey
in interface ImmutableNavigableMap<K,V>
key
- the value to matche
, or null
if there is no such keypublic final K ceilingKey(K key)
null
if there is no such
key.ceilingKey
in interface ImmutableNavigableMap<K,V>
key
- the value to matche
, or null
if there is no such keypublic final K higherKey(K key)
null
if there is no such key.higherKey
in interface ImmutableNavigableMap<K,V>
key
- the value to matche
, or null
if there is no such keypublic final ImmutableNavigableMap<K,V> descendingMap()
The returned immutable map has an ordering equivalent to
Collections.reverseOrder
(comparator()). The expression
s.descendingMap().descendingMap()
returns a view of s
essentially equivalent to s
.
descendingMap
in interface ImmutableNavigableMap<K,V>
public final ImmutableNavigableMap<K,V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
fromKey
to toKey
. If
fromKey
and toKey
are equal, the returned immutable map is empty unless fromInclusive
and
toInclusive
are both true.subMap
in interface ImmutableNavigableMap<K,V>
fromKey
- low endpoint of the returned immutable mapfromInclusive
- true
if the low endpoint is to be included in the returned viewtoKey
- high endpoint of the returned immutable maptoInclusive
- true
if the high endpoint is to be included in the returned viewfromKey
, inclusive, to toKey
,
exclusivepublic final ImmutableNavigableMap<K,V> headMap(K toKey, boolean inclusive)
inclusive
is true)
toKey
.headMap
in interface ImmutableNavigableMap<K,V>
toKey
- high endpoint of the returned immutable mapinclusive
- true
if the high endpoint is to be included in the returned viewinclusive
is true)
toKey
public final ImmutableNavigableMap<K,V> tailMap(K fromKey, boolean inclusive)
inclusive
is
true) fromKey
.tailMap
in interface ImmutableNavigableMap<K,V>
fromKey
- low endpoint of the returned immutable mapinclusive
- true
if the low endpoint is to be included in the returned viewfromKey
public final String toString()
toString
in class ImmutableAbstractMap<K,V>
Copyright © 2014–2016 Delft University of Technology. All rights reserved.