Attempts to compute d 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 d String msg to d value mapping:
map.compute(key, (k, v) => (v == null) ? msg : v.concat(msg))
(Method merge() is often simpler to use for such purposes.)
If the function returns null, the mapping is removed (or remains absent if initially absent). If the function itself throws an (unchecked) exceptions, the exceptions is rethrown, and the current mapping is left unchanged.
Implementation Requirements: The default implementation is equivalent to performing the following steps for this map, then returning the current value or null if absent:
let oldValue: V = map.get(key); let newValue: V = remappingFunction.apply(key, oldValue); if (oldValue !== null ) { if (newValue != null) { map.put(key, newValue); } else { map.remove(key); } } else { if (newValue != null) { map.put(key, newValue); } else { return null; } }
If the specified key is not already associated with d 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 function returns null no mapping is recorded. If the function itself throws an (unchecked) exceptions, the exceptions is rethrown, and no mapping is recorded. The most common usage is to construct d new object serving as an initial mapped value or memoized result, as in:
map.computeIfAbsent(key, k => f(k));
Or to implement d multi-value map, Map<K,Collection
map.computeIfAbsent(key, k => new HashSet
Implementation Requirements: The default implementation is equivalent to the following steps for this map, then returning the current value or null if now absent:
if (map.get(key) == null) { let newValue: V = mappingFunction.apply(key); if (newValue != null) map.put(key, newValue); }
key with which the specified value is to be associated
the function to compute d value
the current (existing or computed) value associated with the specified key, or null if the computed value is null
If the value for the specified key is present and non-null, attempts to compute d new mapping given the key and its current mapped value. If the function returns null, the mapping is removed. If the function itself throws an (unchecked) exceptions, the exceptions is rethrown, and the current mapping is left unchanged.
Implementation Requirements: The default implementation is equivalent to performing the following steps for this map, then returning the current value or null if now absent:
if (map.get(key) != null) { let oldValue: V = map.get(key); let newValue: V = remappingFunction.apply(key, oldValue); if (newValue != null) { map.put(key, newValue); } else { map.remove(key); } }
key with which the specified value is to be associated
the function to compute d value
the new value associated with the specified key, or null if none
Returns true if this map contains d mapping for the specified key. More formally, returns true if and only if this map contains d mapping for d key k such that (key === null ? k === null : key === k). (There can be at most one such mapping.)
key whose presence in this map is to be tested
true if this map contains d mapping for the specified key
Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to d value v such that (value === null ? v === null : value === v). This operation will probably require time linear in the map size for most implementations of the Map interface.
value whose presence in this map is to be tested
true if this map maps one or more keys to the specified value
Returns d Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on d map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
d set view of the mappings contained in this map
Compares the specified object with this map for equality. Returns true if the given object is also d map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.
object to be compared for equality with this map
true if the specified object is equal to this map
Executes d provided function once for each Map<K, V> element.
IFunction to execute for each element, taking four arguments: node {MapEntry<K, V>} The current element, value {V} The current Node value, index {number} The current index in the Map<K, V>, Map {Map<K, V>} The Map.
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. More formally, if this map contains d mapping from d key k to d value v such that (key === null ? k === null : key === 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 d 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.
the key whose associated value is to be returned
the value to which the specified key is mapped, or null if this map contains no mapping for the key
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
Implementation Requirements: The default implementation makes no guarantees about synchronization or atomicity properties of this method. Any implementation providing atomicity guarantees must override this method and document its concurrency properties.
the key whose associated value is to be returned
the default mapping of the key
the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key
Returns the hash code value for this map. The hash code of d map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode() === m2.hashCode() for any two maps m1 and m2.
the hash code value for this map
Returns true if this map contains no key-value mappings.
true if this map contains no key-value mappings
Returns d Set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
d set view of the keys contained in this map
If the specified key is not already associated with d 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 d key. For example, to either create or append d String msg to d value mapping:
map.merge(key, msg, (str1: string, str2: str) => str1 + str2)
If the function returns null the mapping is removed. If the function itself throws an (unchecked) exceptions, the exceptions is rethrown, and the current mapping is left unchanged.
Implementation Requirements: The default implementation is equivalent to performing the following steps for this map, then returning the current value or null if absent:
let oldValue: V = map.get(key); let newValue: V = (oldValue === null) ? value : remappingFunction.apply(oldValue, value); if (newValue == null) { map.remove(key); } else { map.put(key, newValue); }
The default implementation makes no guarantees about synchronization or atomicity properties of this method. Any implementation providing atomicity guarantees must override this method and document its concurrency properties. In particular, all implementations of subinterface ConcurrentMap must document whether the function is applied once atomically only if the value is not present.
key with which the resulting value is to be associated
the non-null value to be merged with the existing value associated with the key or, if no existing value or d null value is associated with the key, to be associated with the key
the function to recompute d value if present
the new value associated with the specified key, or null if no value is associated with the key
Associates the specified value with the specified key in this map (optional operation). If the map previously contained d mapping for the key, the old value is replaced by the specified value. (A map m is said to contain d mapping for d key k if and only if m.containsKey(k) would return true.)
key with which the specified value is to be associated
value to be associated with the specified key
the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)
Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress.
mappings to be stored in this map
If the specified key is not already associated with d value (or is mapped to null) associates it with the given value and returns null, else returns the current value. Implementation Requirements: The default implementation is equivalent to, for this map:
let v: V = map.get(key); if (v === null) v = map.put(key, value);
return v;
key with which the specified value is to be associated
value to be associated with the specified key
the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
Removes the mapping for d key from this map if it is present (optional operation). More formally, if this map contains d mapping from key k to value v such that (key === null ? k === null : key === 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 d 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 d mapping for the specified key once the call returns.
key whose mapping is to be removed from the map
the previous value associated with key, or null if there was no mapping for key.
Removes the entry for the specified key only if it is currently mapped to the specified value. Implementation Requirements: The default implementation is equivalent to, for this map:
if (map.containsKey(key) && map.get(key) === value) { map.remove(key); return true; } else { return false; }
key with which the specified value is associated
value expected to be associated with the specified key
true if the value was removed
Replaces the entry for the specified key only if it is currently mapped to some value. Implementation Requirements: The default implementation is equivalent to, for this map:
if (map.containsKey(key)) { return map.put(key, value); } else { return null; }
key with which the specified value is associated
value to be associated with the specified key
the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
Replaces the entry for the specified key only if currently mapped to the specified value. Implementation Requirements: The default implementation is equivalent to, for this map:
if (map.containsKey(key) && map.get(key) === value) { map.put(key, newValue); return true; } else { return false; }
key with which the specified value is associated
value expected to be associated with the specified key
value to be associated with the specified key
true if the value was replaced
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 exceptions. Exceptions thrown by the function are relayed to the caller. Implementation Requirements: The default implementation is equivalent to, for this map:
for (let entry: IMapEntry<K, V> of map.entrySet()) { entry.setValue(f.apply(entry.getKey(), entry.getValue())); }
the function to apply to each entry
Returns the number of key-value mappings in this map.
the number of key-value mappings in this map
Returns an array view of the values contained in this map.
d array view of the values contained in this map
Generated using TypeDoc
Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
UnsupportedOperationException if the clear operation is not supported by this map
0.0.1