From class NavigableMap
MutableEntry<K, V>? |
ceilingEntry(key: K)
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such key.
|
K? |
ceilingKey(key: K)
Returns the least key greater than or equal to the given key, or null if there is no such key.
|
MutableEntry<K, V>? |
firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
|
MutableEntry<K, V>? |
floorEntry(key: K)
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
|
K? |
floorKey(key: K)
Returns the greatest key less than or equal to the given key, or null if there is no such key.
|
MutableEntry<K, V>? |
higherEntry(key: K)
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
|
K? |
higherKey(key: K)
Returns the least key strictly greater than the given key, or null if there is no such key.
|
MutableEntry<K, V>? |
lastEntry()
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
|
MutableEntry<K, V>? |
lowerEntry(key: K)
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
|
K? |
lowerKey(key: K)
Returns the greatest key strictly less than the given key, or null if there is no such key.
|
MutableEntry<K, V>? |
pollFirstEntry()
Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
|
MutableEntry<K, V>? |
pollLastEntry()
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
|
NavigableMap<K, V> |
reversed()
Returns a reverse-ordered view of this map. The encounter order of mappings in the returned view is the inverse of the encounter order of mappings in this map. The reverse ordering affects all order-sensitive operations, including those on the view collections of the returned view. If the implementation permits modifications to this view, the modifications "write through" to the underlying map. Changes to the underlying map might or might not be visible in this reversed view, depending upon the implementation.
This method is equivalent to descendingMap .
|
|
From class ConcurrentMap
V? |
compute(key: K, remappingFunction: BiFunction<in K, in V?, out V?>)
Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping). For example, to either create or append a String msg to a value mapping:
<code>map.compute(key, (k, v) -> (v == null) ? msg : v.concat(msg))</code>
(Method merge() is often simpler to use for such purposes.)
If the remapping function returns null , the mapping is removed (or remains absent if initially absent). If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
The remapping function should not modify this map during computation.
|
V |
computeIfAbsent(key: K, mappingFunction: Function<in K, out V>)
If the specified key is not already associated with a value (or is mapped to null ), attempts to compute its value using the given mapping function and enters it into this map unless null .
If the mapping function returns null , no mapping is recorded. If the mapping function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded. The most common usage is to construct a new object serving as an initial mapped value or memoized result, as in:
<code>map.computeIfAbsent(key, k -> new Value(f(k)));
</code>
Or to implement a multi-value map, Map<K,Collection<V>> , supporting multiple values per key:
<code>map.computeIfAbsent(key, k -> new HashSet<V>()).add(v);
</code>
The mapping function should not modify this map during computation.
|
V? |
computeIfPresent(key: K, remappingFunction: BiFunction<in K, in V, out V?>)
If the value for the specified key is present and non-null, attempts to compute a new mapping given the key and its current mapped value.
If the remapping function returns null , the mapping is removed. If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
The remapping function should not modify this map during computation.
|
Unit |
forEach(action: BiConsumer<in K, in V>)
Performs the given action for each entry in this map until all entries have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.) Exceptions thrown by the action are relayed to the caller.
|
V |
getOrDefault(key: K, defaultValue: V)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
|
V? |
merge(key: K, value: V, remappingFunction: BiFunction<in V, in V, out V?>)
If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value. Otherwise, replaces the associated value with the results of the given remapping function, or removes if the result is null . This method may be of use when combining multiple mapped values for a key. For example, to either create or append a String msg to a value mapping:
<code>map.merge(key, msg, String::concat)
</code>
If the remapping function returns null , the mapping is removed. If the remapping function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.
The remapping function should not modify this map during computation.
|
V? |
putIfAbsent(key: K, value: V)
If the specified key is not already associated with a value, associates it with the given value. This is equivalent to, for this map :
<code>if (!map.containsKey(key))
return map.put(key, value);
else
return map.get(key);</code>
except that the action is performed atomically.
|
Boolean |
remove(key: K, value: V)
Removes the entry for a key only if currently mapped to a given value. This is equivalent to, for this map :
<code>if (map.containsKey(key)
&& Objects.equals(map.get(key), value)) {
map.remove(key);
return true;
} else {
return false;
}</code>
except that the action is performed atomically.
|
V? |
replace(key: K, value: V)
Replaces the entry for a key only if currently mapped to some value. This is equivalent to, for this map :
<code>if (map.containsKey(key))
return map.put(key, value);
else
return null;</code>
except that the action is performed atomically.
|
Boolean |
replace(key: K, oldValue: V, newValue: V)
Replaces the entry for a key only if currently mapped to a given value. This is equivalent to, for this map :
<code>if (map.containsKey(key)
&& Objects.equals(map.get(key), oldValue)) {
map.put(key, newValue);
return true;
} else {
return false;
}</code>
except that the action is performed atomically.
|
Unit |
replaceAll(function: BiFunction<in K, in V, out V>)
Replaces each entry's value with the result of invoking the given function on that entry until all entries have been processed or the function throws an exception. Exceptions thrown by the function are relayed to the caller.
|
|