public class Object2ObjectRBTreeMap<K,V> extends AbstractObject2ObjectSortedMap<K,V> implements Serializable, Cloneable
The iterators provided by the views of this class are type-specific
bidirectional
iterators. Moreover, the iterator returned by iterator() can be
safely cast to a type-specific list
iterator.
AbstractObject2ObjectMap.BasicEntry<K,V>Object2ObjectSortedMap.FastSortedEntrySet<K,V>Object2ObjectMap.FastEntrySet<K,V>| Constructor and Description |
|---|
Object2ObjectRBTreeMap()
Creates a new empty tree map.
|
Object2ObjectRBTreeMap(Comparator<? super K> c)
Creates a new empty tree map with the given comparator.
|
Object2ObjectRBTreeMap(K[] k,
V[] v)
Creates a new tree map using the elements of two parallel arrays.
|
Object2ObjectRBTreeMap(K[] k,
V[] v,
Comparator<? super K> c)
Creates a new tree map using the elements of two parallel arrays and the
given comparator.
|
Object2ObjectRBTreeMap(Map<? extends K,? extends V> m)
Creates a new tree map copying a given map.
|
Object2ObjectRBTreeMap(Object2ObjectMap<? extends K,? extends V> m)
Creates a new tree map copying a given map.
|
Object2ObjectRBTreeMap(Object2ObjectSortedMap<K,V> m)
Creates a new tree map copying a given sorted map (and its
Comparator). |
Object2ObjectRBTreeMap(SortedMap<K,V> m)
Creates a new tree map copying a given sorted map (and its
Comparator). |
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Removes all of the mappings from this map (optional operation).
|
Object2ObjectRBTreeMap<K,V> |
clone()
Returns a deep copy of this tree map.
|
Comparator<? super K> |
comparator()
Returns the comparator associated with this sorted set, or null if it
uses its keys' natural ordering.
|
boolean |
containsKey(Object k)
Returns true if this function contains a mapping for the specified key.
|
boolean |
containsValue(Object v)
Returns true if this map maps one or more keys to the
specified value.
|
K |
firstKey()
Returns the first (lowest) key currently in this map.
|
V |
get(Object k)
Returns the value to which the specified key is mapped,
or
null if this map contains no mapping for the key. |
Object2ObjectSortedMap<K,V> |
headMap(K to)
Returns a view of the portion of this sorted map whose keys are strictly
less than
toKey. |
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
ObjectSortedSet<K> |
keySet()
Returns a type-specific sorted set view of the keys contained in this
map.
|
K |
lastKey()
Returns the last (highest) key currently in this map.
|
ObjectSortedSet<Object2ObjectMap.Entry<K,V>> |
object2ObjectEntrySet()
Returns a type-specific sorted-set view of the mappings contained in this
map.
|
V |
put(K k,
V v)
Associates the specified value with the specified key in this map
(optional operation).
|
V |
remove(Object k)
Removes the mapping for a key from this map if it is present
(optional operation).
|
int |
size()
Returns the number of key-value mappings in this map.
|
Object2ObjectSortedMap<K,V> |
subMap(K from,
K to)
Returns a view of the portion of this sorted map whose keys range from
fromKey, inclusive, to toKey, exclusive. |
Object2ObjectSortedMap<K,V> |
tailMap(K from)
Returns a view of the portion of this sorted map whose keys are greater
than or equal to
fromKey. |
ObjectCollection<V> |
values()
Returns a type-specific collection view of the values contained in this
map.
|
equals, hashCode, putAll, toStringdefaultReturnValue, defaultReturnValueentrySetdefaultReturnValue, defaultReturnValuecompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putAll, putIfAbsent, remove, replace, replace, replaceAllpublic Object2ObjectRBTreeMap()
public Object2ObjectRBTreeMap(Comparator<? super K> c)
c - a (possibly type-specific) comparator.public Object2ObjectRBTreeMap(Map<? extends K,? extends V> m)
m - a Map to be copied into the new tree map.public Object2ObjectRBTreeMap(SortedMap<K,V> m)
Comparator).m - a SortedMap to be copied into the new tree map.public Object2ObjectRBTreeMap(Object2ObjectMap<? extends K,? extends V> m)
m - a type-specific map to be copied into the new tree map.public Object2ObjectRBTreeMap(Object2ObjectSortedMap<K,V> m)
Comparator).m - a type-specific sorted map to be copied into the new tree map.public Object2ObjectRBTreeMap(K[] k, V[] v, Comparator<? super K> c)
k - the array of keys of the new tree map.v - the array of corresponding values in the new tree map.c - a (possibly type-specific) comparator.IllegalArgumentException - if k and v have different lengths.public Object2ObjectRBTreeMap(K[] k, V[] v)
k - the array of keys of the new tree map.v - the array of corresponding values in the new tree map.IllegalArgumentException - if k and v have different lengths.public V put(K k, V v)
java.util.Mapm.containsKey(k) would return
true.)put in interface Object2ObjectFunction<K,V>put in interface Object2ObjectMap<K,V>put in interface Map<K,V>k - key with which the specified value is to be associatedv - value to be associated with the specified keyFunction.put(Object,Object)public V remove(Object k)
java.util.Map(key==null ? k==null : key.equals(k)), that mapping
is removed. (The map can contain at most one such mapping.)
Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.
If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.
The map will not contain a mapping for the specified key once the call returns.
remove in interface Object2ObjectFunction<K,V>remove in interface Object2ObjectMap<K,V>remove in interface Map<K,V>k - key whose mapping is to be removed from the mapFunction.remove(Object)public boolean containsValue(Object v)
java.util.MapcontainsValue in interface Map<K,V>containsValue in class AbstractObject2ObjectMap<K,V>v - value whose presence in this map is to be testedpublic void clear()
java.util.Mapclear in interface Object2ObjectMap<K,V>clear in interface Map<K,V>Map.clear()public boolean containsKey(Object k)
Object2ObjectMapcontainsKey in interface Object2ObjectMap<K,V>containsKey in interface Map<K,V>containsKey in class AbstractObject2ObjectMap<K,V>k - the key.key.Map.containsKey(Object)public int size()
java.util.Mappublic boolean isEmpty()
java.util.Mappublic V get(Object k)
java.util.Mapnull if this map contains no mapping for the key.
More formally, if this map contains a mapping from a key
k to a value v such that (key==null ? k==null :
key.equals(k)), then this method returns v; otherwise
it returns null. (There can be at most one such mapping.)
If this map permits null values, then a return value of
null does not necessarily indicate that the map
contains no mapping for the key; it's also possible that the map
explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
get in interface Object2ObjectFunction<K,V>get in interface Map<K,V>k - the key whose associated value is to be returnednull if this map contains no mapping for the keyFunction.get(Object)public K firstKey()
java.util.SortedMappublic K lastKey()
java.util.SortedMappublic ObjectSortedSet<Object2ObjectMap.Entry<K,V>> object2ObjectEntrySet()
Object2ObjectSortedMapNote that this specification strengthens the one given in the corresponding type-specific unsorted map.
object2ObjectEntrySet in interface Object2ObjectMap<K,V>object2ObjectEntrySet in interface Object2ObjectSortedMap<K,V>Object2ObjectSortedMap.entrySet()public ObjectSortedSet<K> keySet()
In addition to the semantics of Map.keySet(), you can
safely cast the set returned by this call to a type-specific sorted set
interface.
keySet in interface Object2ObjectMap<K,V>keySet in interface Object2ObjectSortedMap<K,V>keySet in interface Map<K,V>keySet in interface SortedMap<K,V>keySet in class AbstractObject2ObjectSortedMap<K,V>Map.keySet()public ObjectCollection<V> values()
In addition to the semantics of Map.values(), you can
safely cast the collection returned by this call to a type-specific
collection interface.
values in interface Object2ObjectMap<K,V>values in interface Object2ObjectSortedMap<K,V>values in interface Map<K,V>values in interface SortedMap<K,V>values in class AbstractObject2ObjectSortedMap<K,V>Map.values()public Comparator<? super K> comparator()
Object2ObjectSortedMap
Note that this specification strengthens the one given in
SortedMap.comparator().
comparator in interface Object2ObjectSortedMap<K,V>comparator in interface SortedMap<K,V>null if this map uses the natural ordering
of its keysSortedMap.comparator()public Object2ObjectSortedMap<K,V> headMap(K to)
Object2ObjectSortedMaptoKey.
Note that this specification strengthens the one given in
SortedMap.headMap(Object).
headMap in interface Object2ObjectSortedMap<K,V>headMap in interface SortedMap<K,V>to - high endpoint (exclusive) of the keys in the returned maptoKeySortedMap.headMap(Object)public Object2ObjectSortedMap<K,V> tailMap(K from)
Object2ObjectSortedMapfromKey.
Note that this specification strengthens the one given in
SortedMap.tailMap(Object).
tailMap in interface Object2ObjectSortedMap<K,V>tailMap in interface SortedMap<K,V>from - low endpoint (inclusive) of the keys in the returned mapfromKeySortedMap.tailMap(Object)public Object2ObjectSortedMap<K,V> subMap(K from, K to)
Object2ObjectSortedMapfromKey, inclusive, to toKey, exclusive.
Note that this specification strengthens the one given in
SortedMap.subMap(Object,Object).
subMap in interface Object2ObjectSortedMap<K,V>subMap in interface SortedMap<K,V>from - low endpoint (inclusive) of the keys in the returned mapto - high endpoint (exclusive) of the keys in the returned mapfromKey, inclusive, to toKey, exclusiveSortedMap.subMap(Object,Object)public Object2ObjectRBTreeMap<K,V> clone()
This method performs a deep copy of this tree map; the data stored in the set, however, is not cloned. Note that this makes a difference only for object keys.