Options
All
  • Public
  • Public/Protected
  • All
Menu

Type parameters

  • K

  • V

Hierarchy

  • IMap

Implemented by

Index

Methods

clear

  • clear(): void
  • Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

    throws

    UnsupportedOperationException if the clear operation is not supported by this map

    since

    0.0.1

    Returns void

compute

  • compute(key: K, remappingFunction: IBiFunction<K, V, V>): V
  • 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; } }

    since

    0.0.1

    Parameters

    Returns V

computeIfAbsent

  • computeIfAbsent(key: K, mappingFunction: IFunction<K, V>): V
  • 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>, supporting multiple values per key:

    map.computeIfAbsent(key, k => new HashSet()).add(v);

    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); }

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is to be associated

    • mappingFunction: IFunction<K, V>

      the function to compute d value

    Returns V

    the current (existing or computed) value associated with the specified key, or null if the computed value is null

computeIfPresent

  • 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); } }

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is to be associated

    • v: IBiFunction<K, V, V>

      the function to compute d value

    Returns V

    the new value associated with the specified key, or null if none

containsKey

  • containsKey(key: any): boolean
  • 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.)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: any

      key whose presence in this map is to be tested

    Returns boolean

    true if this map contains d mapping for the specified key

containsValue

  • containsValue(value: any): boolean
  • 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.

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • value: any

      value whose presence in this map is to be tested

    Returns boolean

    true if this map maps one or more keys to the specified value

entrySet

  • 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.

    since

    0.0.1

    Returns ISet<IMapEntry<K, V>>

    d set view of the mappings contained in this map

equals

  • equals(m: IMap<K, V>): boolean
  • 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.

    since

    0.0.1

    Parameters

    • m: IMap<K, V>

      object to be compared for equality with this map

    Returns boolean

    true if the specified object is equal to this map

forEach

  • Executes d provided function once for each Map<K, V> element.

    since

    0.0.1

    Parameters

    • callback: IFunction<IMapEntry<K, V>, IMapEntry<K, V>>

      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 void

get

  • get(key: K): V
  • 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.

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      the key whose associated value is to be returned

    Returns V

    the value to which the specified key is mapped, or null if this map contains no mapping for the key

getOrDefault

  • getOrDefault(key: K, defaultValue: V): V
  • 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.

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      the key whose associated value is to be returned

    • defaultValue: V

      the default mapping of the key

    Returns V

    the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key

hashCode

  • hashCode(): number
  • 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.

    since

    0.0.1

    Returns number

    the hash code value for this map

isEmpty

  • isEmpty(): boolean
  • Returns true if this map contains no key-value mappings.

    since

    0.0.1

    Returns boolean

    true if this map contains no key-value mappings

keySet

  • 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.

    since

    0.0.1

    Returns ISet<K>

    d set view of the keys contained in this map

merge

  • merge(key: K, value: V, remappingFunction: IBiFunction<V, V, V>): V
  • 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.

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      key with which the resulting value is to be associated

    • value: V

      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

    • remappingFunction: IBiFunction<V, V, V>

      the function to recompute d value if present

    Returns V

    the new value associated with the specified key, or null if no value is associated with the key

put

  • put(key: K, value: V): V
  • 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.)

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    throws

    IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is to be associated

    • value: V

      value to be associated with the specified key

    Returns V

    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.)

putAll

  • putAll(m: IMap<K, V>): void
  • 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.

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    throws

    IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map

    since

    0.0.1

    Parameters

    • m: IMap<K, V>

      mappings to be stored in this map

    Returns void

putIfAbsent

  • putIfAbsent(key: K, value: V): V
  • 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;

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    throws

    IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is to be associated

    • value: V

      value to be associated with the specified key

    Returns V

    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.)

remove

  • remove(key: K): V
  • remove(key: K, value: V): boolean
  • 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.

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      key whose mapping is to be removed from the map

    Returns V

    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; }

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is associated

    • value: V

      value expected to be associated with the specified key

    Returns boolean

    true if the value was removed

replace

  • replace(key: K, value: V): V
  • replace(key: K, oldValue: V, newValue: V): boolean
  • 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; }

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of the specified key or value prevents it from being stored in this map (optional)

    throws

    NullReferenceException - if the specified key is null and this map does not support null keys, or the mappingFunction is null

    throws

    IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is associated

    • value: V

      value to be associated with the specified key

    Returns V

    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; }

    throws

    UnsupportedOperationException - if the put operation is not supported by this map (optional)

    throws

    ClassCastException - if the class of d specified key or value prevents it from being stored in this map

    throws

    NullReferenceException - if d specified key or newValue is null, and this map does not permit null keys or values

    throws

    NullReferenceException - if oldValue is null and this map does not permit null values (optional)

    throws

    IllegalArgumentException - if some property of d specified key or value prevents it from being stored in this map

    since

    0.0.1

    Parameters

    • key: K

      key with which the specified value is associated

    • oldValue: V

      value expected to be associated with the specified key

    • newValue: V

      value to be associated with the specified key

    Returns boolean

    true if the value was replaced

replaceAll

  • 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())); }

    throws

    UnsupportedOperationException - if the set operation is not supported by this map's entry set iterator.

    throws

    ClassCastException - if the class of d replacement value prevents it from being stored in this map

    throws

    NullReferenceException - if the specified function is null, or the specified replacement value is null, and this map does not permit null values

    throws

    ClassCastException - if d replacement value is of an inappropriate type for this map (optional)

    throws

    NullReferenceException - if function or d replacement value is null, and this map does not permit null keys or values (optional)

    throws

    IllegalArgumentException - if some property of d replacement value prevents it from being stored in this map (optional)

    since

    0.0.1

    Parameters

    • f: IBiFunction<K, V, V>

      the function to apply to each entry

    Returns void

size

  • size(): number

values

  • values(): V[]
  • Returns an array view of the values contained in this map.

    since

    0.0.1

    Returns V[]

    d array view of the values contained in this map

Generated using TypeDoc