Skip to content
Buy me a coffee

SequencedMap

Defined in: src/interfaces/Map.ts:178

A map with a defined encounter order and two accessible ends (LinkedHashMap, TreeMap). The first/last entry methods return immutable snapshots, or null when the map is empty.

  • Map<K, V>

K

V

[iterator](): Iterator<[K, V], any, any>

Defined in: site/node_modules/typescript/lib/lib.es2015.iterable.d.ts:47

Iterator<[K, V], any, any>

Map.[iterator]


clear(): void

Defined in: src/interfaces/Map.ts:87

Removes all mappings.

void

UnsupportedOperationException if this map is unmodifiable

Map.clear


compute(key, fn): V | null

Defined in: src/interfaces/Map.ts:163

Stores fn(key, current), where current is the mapped value or null; a null/undefined result removes the mapping (or leaves the key absent).

K

(key, value) => V | null | undefined

V | null

the new value, or null if there is now no mapping

NullPointerException if fn is null

ConcurrentModificationException if fn structurally modifies this map (hashed and tree maps detect it)

Map.compute


computeIfAbsent(key, fn): V | null

Defined in: src/interfaces/Map.ts:148

If key is absent or mapped to null, stores fn(key) unless that is null/undefined (then nothing is stored).

K

(key) => V | null | undefined

V | null

the existing non-null value, the newly stored value, or null

NullPointerException if fn is null

ConcurrentModificationException if fn structurally modifies this map (hashed and tree maps detect it)

Map.computeIfAbsent


computeIfPresent(key, fn): V | null

Defined in: src/interfaces/Map.ts:155

If key has a non-null value, replaces it with fn(key, value); a null/undefined result removes the mapping.

K

(key, value) => V | null | undefined

V | null

the new value, or null if the key was absent or has been removed

NullPointerException if fn is null

ConcurrentModificationException if fn structurally modifies this map (hashed and tree maps detect it)

Map.computeIfPresent


containsKey(key): boolean

Defined in: src/interfaces/Map.ts:49

Returns true if this map has a mapping for key, even if it maps to null.

unknown

boolean

NullPointerException if key is null and this map rejects null keys

Map.containsKey


containsValue(value): boolean

Defined in: src/interfaces/Map.ts:51

Returns true if one or more keys map to a value equal to value. Usually O(n).

unknown

boolean

Map.containsValue


entrySet(): Set<MapEntry<K, V>>

Defined in: src/interfaces/Map.ts:102

Returns a live view of the mappings. Its entries are live (setValue writes through), removing from it removes the mapping, and it does not support add (UnsupportedOperationException).

Set<MapEntry<K, V>>

Map.entrySet


equals(o): boolean

Defined in: src/interfaces/Map.ts:104

Returns true if o is a map with the same mappings, whatever its class.

unknown

boolean

Map.equals


firstEntry(): MapEntry<K, V> | null

Defined in: src/interfaces/Map.ts:182

Returns the first entry as an immutable snapshot, or null if this map is empty.

MapEntry<K, V> | null


forEach(action): void

Defined in: src/interfaces/Map.ts:119

Calls action for each mapping, in iteration order.

(key, value) => void

void

NullPointerException if action is null

ConcurrentModificationException if action structurally modifies this map

Map.forEach


get(key): V | null

Defined in: src/interfaces/Map.ts:56

Returns the value mapped to key, or null if there is none (or the key maps to null).

unknown

V | null

NullPointerException if key is null and this map rejects null keys

Map.get


getOrDefault(key, defaultValue): V

Defined in: src/interfaces/Map.ts:111

Returns the value mapped to key, or defaultValue if there is no mapping. A key mapped to null returns null.

unknown

V

V

Map.getOrDefault

getOrDefault(key, defaultValue): V | null

Defined in: src/interfaces/Map.ts:113

Returns the value mapped to key, or defaultValue (here possibly null) if there is no mapping.

unknown

V | null

V | null

Map.getOrDefault


hashCode(): number

Defined in: src/interfaces/Map.ts:106

Returns the sum over all entries of hash(key) ^ hash(value), in 32-bit arithmetic.

number

Map.hashCode


isEmpty(): boolean

Defined in: src/interfaces/Map.ts:44

Returns true if this map has no mappings.

boolean

Map.isEmpty


keySet(): Set<K>

Defined in: src/interfaces/Map.ts:92

Returns a live view of the keys. Removing from it removes the mapping; it does not support add (UnsupportedOperationException).

Set<K>

Map.keySet


lastEntry(): MapEntry<K, V> | null

Defined in: src/interfaces/Map.ts:184

Returns the last entry as an immutable snapshot, or null if this map is empty.

MapEntry<K, V> | null


merge(key, value, fn): V | null

Defined in: src/interfaces/Map.ts:171

If key is absent or mapped to null, maps it to value; otherwise stores fn(oldValue, value), and a null/undefined result removes the mapping. merge(k, 1, (a, b) => a + b) counts occurrences.

K

V

(oldValue, value) => V | null | undefined

V | null

the new value, or null if the mapping was removed

NullPointerException if value or fn is null

ConcurrentModificationException if fn structurally modifies this map (hashed and tree maps detect it)

Map.merge


pollFirstEntry(): MapEntry<K, V> | null

Defined in: src/interfaces/Map.ts:186

Removes and returns the first entry as an immutable snapshot, or null if this map is empty.

MapEntry<K, V> | null


pollLastEntry(): MapEntry<K, V> | null

Defined in: src/interfaces/Map.ts:188

Removes and returns the last entry as an immutable snapshot, or null if this map is empty.

MapEntry<K, V> | null


put(key, value): V | null

Defined in: src/interfaces/Map.ts:64

Maps key to value, replacing any previous value.

K

V

V | null

the previous value, or null if there was no mapping

UnsupportedOperationException if this map is unmodifiable

NullPointerException if key or value is null and this map rejects it

IllegalArgumentException if key is outside the range of a sorted map view

Map.put


putAll(m): void

Defined in: src/interfaces/Map.ts:82

Copies every mapping of m into this map, as put would.

Map<K, V>

void

NullPointerException if m is null

UnsupportedOperationException if this map is unmodifiable

Map.putAll


putFirst(key, value): V | null

Defined in: src/interfaces/Map.ts:194

Maps key to value and moves the mapping to the front.

K

V

V | null

the previous value, or null if there was no mapping

UnsupportedOperationException if this map is sorted or unmodifiable


putIfAbsent(key, value): V | null

Defined in: src/interfaces/Map.ts:131

Maps key to value if it is absent or mapped to null.

K

V

V | null

the current value if it was non-null (and nothing changed), otherwise null

UnsupportedOperationException if this map is unmodifiable

Map.putIfAbsent


putLast(key, value): V | null

Defined in: src/interfaces/Map.ts:200

Maps key to value and moves the mapping to the end.

K

V

V | null

the previous value, or null if there was no mapping

UnsupportedOperationException if this map is sorted or unmodifiable


remove(key): V | null

Defined in: src/interfaces/Map.ts:70

Removes the mapping for key, if present.

unknown

V | null

the removed value, or null if there was no mapping

UnsupportedOperationException if this map is unmodifiable

Map.remove

remove(key, value): boolean

Defined in: src/interfaces/Map.ts:76

Removes the mapping for key only if it is currently mapped to a value equal to value.

unknown

unknown

boolean

true if the mapping was removed

UnsupportedOperationException if this map is unmodifiable

Map.remove


replace(key, value): V | null

Defined in: src/interfaces/Map.ts:136

Replaces the value for key only if key currently has a mapping (even to null).

K

V

V | null

the previous value, or null if there was no mapping

Map.replace

replace(key, oldValue, newValue): boolean

Defined in: src/interfaces/Map.ts:141

Replaces the value for key with newValue only if it is currently mapped to a value equal to oldValue.

K

V

V

boolean

true if the value was replaced

Map.replace


replaceAll(fn): void

Defined in: src/interfaces/Map.ts:125

Replaces each value with fn(key, value), in iteration order.

(key, value) => V

void

NullPointerException if fn is null, or it returns null and this map rejects null values

UnsupportedOperationException if this map is unmodifiable

Map.replaceAll


reversed(): SequencedMap<K, V>

Defined in: src/interfaces/Map.ts:180

Returns a live reverse-ordered view: changes through either side are visible in the other.

SequencedMap<K, V>


sequencedEntrySet(): SequencedSet<MapEntry<K, V>>

Defined in: src/interfaces/Map.ts:206

Returns a live, sequenced view of the mappings.

SequencedSet<MapEntry<K, V>>


sequencedKeySet(): SequencedSet<K>

Defined in: src/interfaces/Map.ts:202

Returns a live, sequenced view of the keys.

SequencedSet<K>


sequencedValues(): SequencedCollection<V>

Defined in: src/interfaces/Map.ts:204

Returns a live, sequenced view of the values.

SequencedCollection<V>


size(): number

Defined in: src/interfaces/Map.ts:42

Returns the number of mappings.

number

Map.size


toString(): string

Defined in: src/interfaces/Map.ts:108

Returns the mappings in iteration order as {k1=v1, k2=v2}; a key or value that is this map prints as (this Map).

string

Map.toString


values(): Collection<V>

Defined in: src/interfaces/Map.ts:97

Returns a live view of the values. Removing from it removes the mapping; it does not support add (UnsupportedOperationException).

Collection<V>

Map.values