javascript-collections-framework
    Preparing search index...

    Interface MapEntry<K, V>

    One key–value mapping of a map: a live handle on one key of one map.

    key is the stored key. value reads the map's current value while the key is present, and afterwards the value it last returned. Destructuring yields the same two: const [k, v] = entry. Two entries are equal when their keys and values are equal under equals.

    for (const entry of map.entrySet()) {
    if (entry.value < 0) entry.setValue(0)
    }
    interface MapEntry<K, V> {
        key: K;
        value: V;
        "[equalsSymbol]"(other: unknown): boolean;
        "[hashCodeSymbol]"(hash: HashFunction): number;
        "[iterator]"(): Iterator<K | V, any, any>;
        equals(other: unknown): boolean;
        setValue(value: V): V;
        toJSON(): [K, V];
        toString(): string;
    }

    Type Parameters

    • K
    • V

    Hierarchy

    • Iterable<K | V>
      • MapEntry
    Index
    key: K

    The key of the mapping. Time: O(1).

    value: V

    The current value of the mapping while its key is present in the map; afterwards, the value this entry last returned or wrote. Time: as the map documents — O(1) average for a HashMap; O(1) while the mapping is stored and O(log n) once it has left the map for a TreeMap.

    • The value-equality protocol; delegates to equals. Time: as equals.

      Parameters

      • other: unknown

      Returns boolean

    • The value-equality protocol: the same for equal entries. Time: as value, plus the calls.

      Parameters

      Returns number

    • Returns Iterator<K | V, any, any>

    • Returns whether other is an entry whose key and value are equal to this entry's under equals.

      Time: as reading value, plus the protocol methods.

      Parameters

      • other: unknown

        Any value.

      Returns boolean

      true when other is an equal entry.

    • Writes value to the mapping in the map and returns the value it replaced.

      Time: as the map documents (as value).

      Parameters

      • value: V

        The new value.

      Returns V

      The previous value.

      IllegalStateError when the key is no longer present in the map.

    • Returns [key, value], so JSON.stringify writes an entry as a pair.

      Time: as value.

      Returns [K, V]

      A new two-element array.

    • Returns the mapping as text, e.g. 'a' => 1.

      Time: as value, plus O(length of the output).

      Returns string

      The text.