AbstractMap
Defined in: src/abstract/AbstractMap.ts:24
Skeleton implementation of the Map interface, built entirely on entrySet().
A read-only subclass implements entrySet() and inherits the whole Map interface: lookups, live keySet() and
values() views, value equals/hashCode with any Map, toString(), for..of over [key, value] pairs, and
the default methods (getOrDefault, putIfAbsent, replace, compute*, merge, …). To make it modifiable,
override put(key, value) (which throws UnsupportedOperationException by default) and give the entry set
an iterator whose remove() works (and entries whose setValue works, for replaceAll).
Lookups are linear scans of the entry set; override the protected findEntry (or the lookup methods) for faster
access. There is no modCount: fail-fast behaviour is whatever the entry-set iterator provides.
A null value from get means “absent”, so the defaults treat a key mapped to null like a missing key where
the Map contract says so.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”K
V
Implements
Section titled “Implements”Map<K,V>
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new AbstractMap<
K,V>():AbstractMap<K,V>
Returns
Section titled “Returns”AbstractMap<K, V>
Methods
Section titled “Methods”[INSPECT]()
Section titled “[INSPECT]()”[INSPECT]():
string
Defined in: src/abstract/AbstractMap.ts:187
Node’s util.inspect hook: console.log prints the toString() form.
Returns
Section titled “Returns”string
[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<[K,V]>
Defined in: src/abstract/AbstractMap.ts:146
Makes the map usable with for..of and spread, yielding [key, value] pairs in entry-set order.
Returns
Section titled “Returns”IterableIterator<[K, V]>
Implementation of
Section titled “Implementation of”Map.[iterator]
clear()
Section titled “clear()”clear():
void
Defined in: src/abstract/AbstractMap.ts:125
Removes every mapping via entrySet().clear().
Returns
Section titled “Returns”void
Implementation of
Section titled “Implementation of”Map.clear
compute()
Section titled “compute()”compute(
key,fn):V|null
Defined in: src/abstract/AbstractMap.ts:301
Puts fn(key, currentValueOrNull), or removes the mapping when fn returns null/undefined; returns the new
value or null.
Parameters
Section titled “Parameters”K
(key, value) => V | null | undefined
Returns
Section titled “Returns”V | null
Throws
Section titled “Throws”NullPointerException if fn is null
Implementation of
Section titled “Implementation of”Map.compute
computeIfAbsent()
Section titled “computeIfAbsent()”computeIfAbsent(
key,fn):V|null
Defined in: src/abstract/AbstractMap.ts:268
If key has no value (absent or mapped to null), puts fn(key) unless it returns null/undefined; returns
the current (possibly new) value, or null.
Parameters
Section titled “Parameters”K
(key) => V | null | undefined
Returns
Section titled “Returns”V | null
Throws
Section titled “Throws”NullPointerException if fn is null
Implementation of
Section titled “Implementation of”Map.computeIfAbsent
computeIfPresent()
Section titled “computeIfPresent()”computeIfPresent(
key,fn):V|null
Defined in: src/abstract/AbstractMap.ts:283
If key has a non-null value, replaces it with fn(key, value), or removes the mapping when fn returns
null/undefined; returns the new value or null.
Parameters
Section titled “Parameters”K
(key, value) => V | null | undefined
Returns
Section titled “Returns”V | null
Throws
Section titled “Throws”NullPointerException if fn is null
Implementation of
Section titled “Implementation of”Map.computeIfPresent
containsKey()
Section titled “containsKey()”containsKey(
key):boolean
Defined in: src/abstract/AbstractMap.ts:63
Returns true if findEntry(key) finds a mapping (a linear scan by default).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.containsKey
containsValue()
Section titled “containsValue()”containsValue(
value):boolean
Defined in: src/abstract/AbstractMap.ts:68
Returns true if some mapping’s value equals value; always a linear scan of the entry set.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.containsValue
entrySet()
Section titled “entrySet()”
abstractentrySet():Set<MapEntry<K,V>>
Defined in: src/abstract/AbstractMap.ts:26
Returns the set of mappings that every other method is built on. Subclasses implement it.
Returns
Section titled “Returns”Set<MapEntry<K, V>>
Implementation of
Section titled “Implementation of”Map.entrySet
equals()
Section titled “equals()”equals(
o):boolean
Defined in: src/abstract/AbstractMap.ts:158
Returns true if o is a Map with the same mappings (any Map implementation). A
ClassCastException or NullPointerException from o’s lookups counts as “not equal”.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.equals
forEach()
Section titled “forEach()”forEach(
action):void
Defined in: src/abstract/AbstractMap.ts:220
Calls action(key, value) for each mapping in entry-set order.
Parameters
Section titled “Parameters”action
Section titled “action”(key, value) => void
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if action is null
Implementation of
Section titled “Implementation of”Map.forEach
get(
key):V|null
Defined in: src/abstract/AbstractMap.ts:75
Returns the value mapped to key, or null if there is none; uses findEntry (a linear scan by default).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”V | null
Implementation of
Section titled “Implementation of”Map.get
getOrDefault()
Section titled “getOrDefault()”Call Signature
Section titled “Call Signature”getOrDefault(
key,defaultValue):V
Defined in: src/abstract/AbstractMap.ts:206
Returns the value mapped to key, or defaultValue when there is no mapping (a mapping to null returns null).
Parameters
Section titled “Parameters”unknown
defaultValue
Section titled “defaultValue”V
Returns
Section titled “Returns”V
Implementation of
Section titled “Implementation of”Map.getOrDefault
Call Signature
Section titled “Call Signature”getOrDefault(
key,defaultValue):V|null
Defined in: src/abstract/AbstractMap.ts:209
Returns the value mapped to key, or defaultValue when there is no mapping (a mapping to null returns null).
Parameters
Section titled “Parameters”unknown
defaultValue
Section titled “defaultValue”V | null
Returns
Section titled “Returns”V | null
Implementation of
Section titled “Implementation of”Map.getOrDefault
hashCode()
Section titled “hashCode()”hashCode():
number
Defined in: src/abstract/AbstractMap.ts:179
Returns the sum of hashCode(key) ^ hashCode(value) over the mappings, so equal maps hash the same.
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”Map.hashCode
isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/abstract/AbstractMap.ts:37
Returns size() === 0.
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.isEmpty
keySet()
Section titled “keySet()”keySet():
Set<K>
Defined in: src/abstract/AbstractMap.ts:133
Returns a live view of the keys, backed by the entry set (created once and cached). It supports removal but not addition.
Returns
Section titled “Returns”Set<K>
Implementation of
Section titled “Implementation of”Map.keySet
merge()
Section titled “merge()”merge(
key,value,fn):V|null
Defined in: src/abstract/AbstractMap.ts:318
Puts value if key has no value (absent or mapped to null), otherwise fn(oldValue, value); removes the
mapping when fn returns null/undefined. Returns the new value or null.
Parameters
Section titled “Parameters”K
V
(oldValue, value) => V | null | undefined
Returns
Section titled “Returns”V | null
Throws
Section titled “Throws”NullPointerException if fn or value is null
Implementation of
Section titled “Implementation of”Map.merge
put(
_key,_value):V|null
Defined in: src/abstract/AbstractMap.ts:84
Maps key to value and returns the previous value, or null. Not supported by default.
Parameters
Section titled “Parameters”K
_value
Section titled “_value”V
Returns
Section titled “Returns”V | null
Throws
Section titled “Throws”UnsupportedOperationException unless a subclass overrides it
Implementation of
Section titled “Implementation of”Map.put
putAll()
Section titled “putAll()”putAll(
m):void
Defined in: src/abstract/AbstractMap.ts:119
Calls put for each mapping of a snapshot of m’s entries.
Parameters
Section titled “Parameters”Map<K, V>
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if m is null
Throws
Section titled “Throws”UnsupportedOperationException if put is not supported and m is not empty
Implementation of
Section titled “Implementation of”Map.putAll
putIfAbsent()
Section titled “putIfAbsent()”putIfAbsent(
key,value):V|null
Defined in: src/abstract/AbstractMap.ts:244
If key has no value (absent or mapped to null), puts value and returns the previous value; else returns the current value.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”V | null
Implementation of
Section titled “Implementation of”Map.putIfAbsent
remove()
Section titled “remove()”Call Signature
Section titled “Call Signature”remove(
key):V|null
Defined in: src/abstract/AbstractMap.ts:92
Removes the mapping for key through the entry-set iterator’s remove() and returns its value, or null if
there was none.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”V | null
Implementation of
Section titled “Implementation of”Map.remove
Call Signature
Section titled “Call Signature”remove(
key,value):boolean
Defined in: src/abstract/AbstractMap.ts:94
Removes the mapping for key only if it is mapped to a value equal to value; returns true if removed.
Parameters
Section titled “Parameters”unknown
unknown
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.remove
replace()
Section titled “replace()”Call Signature
Section titled “Call Signature”replace(
key,value):V|null
Defined in: src/abstract/AbstractMap.ts:250
Puts value only if key already has a mapping; returns the previous value, or null if there was no mapping.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”V | null
Implementation of
Section titled “Implementation of”Map.replace
Call Signature
Section titled “Call Signature”replace(
key,oldValue,newValue):boolean
Defined in: src/abstract/AbstractMap.ts:252
Puts newValue only if key is mapped to a value equal to oldValue; returns true if replaced.
Parameters
Section titled “Parameters”K
oldValue
Section titled “oldValue”V
newValue
Section titled “newValue”V
Returns
Section titled “Returns”boolean
Implementation of
Section titled “Implementation of”Map.replace
replaceAll()
Section titled “replaceAll()”replaceAll(
fn):void
Defined in: src/abstract/AbstractMap.ts:234
Replaces each value with fn(key, value), through the entries’ setValue.
Parameters
Section titled “Parameters”(key, value) => V
Returns
Section titled “Returns”void
Throws
Section titled “Throws”NullPointerException if fn is null
Throws
Section titled “Throws”UnsupportedOperationException if the entries do not support setValue
Implementation of
Section titled “Implementation of”Map.replaceAll
size()
Section titled “size()”size():
number
Defined in: src/abstract/AbstractMap.ts:32
Returns entrySet().size().
Returns
Section titled “Returns”number
Implementation of
Section titled “Implementation of”Map.size
toString()
Section titled “toString()”toString():
string
Defined in: src/abstract/AbstractMap.ts:191
Returns {k1=v1, k2=v2} in entry-set order; a key or value that is this map prints as (this Map).
Returns
Section titled “Returns”string
Implementation of
Section titled “Implementation of”Map.toString
values()
Section titled “values()”values():
Collection<V>
Defined in: src/abstract/AbstractMap.ts:141
Returns a live view of the values, backed by the entry set (created once and cached). It supports removal but not addition.
Returns
Section titled “Returns”Collection<V>
Implementation of
Section titled “Implementation of”Map.values