IdentityHashMap
Defined in: src/map/IdentityHashMap.ts:66
A Map whose keys and values compare by reference (===, except NaN equals NaN; equals() and
hashCode() are ignored). containsValue, remove(k, v), replace(k, old, new), entry and map equality, and the
views all use that rule. Use it when the object itself matters, not its value, e.g. visited nodes in a graph walk.
Backed by a native Map, which uses exactly that key rule. null and undefined keys and values are allowed;
iteration order is unspecified. get, put, containsKey and remove are O(1); iterators are fail-fast.
Extends
Section titled “Extends”AbstractMap<K,V>
Type Parameters
Section titled “Type Parameters”K
V
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new IdentityHashMap<
K,V>():IdentityHashMap<K,V>
Defined in: src/map/IdentityHashMap.ts:76
Creates an empty map.
Returns
Section titled “Returns”IdentityHashMap<K, V>
Overrides
Section titled “Overrides”Constructor
Section titled “Constructor”new IdentityHashMap<
K,V>(expectedMaxSize):IdentityHashMap<K,V>
Defined in: src/map/IdentityHashMap.ts:81
Creates an empty map; expectedMaxSize is a validated sizing hint only.
Parameters
Section titled “Parameters”expectedMaxSize
Section titled “expectedMaxSize”number
Returns
Section titled “Returns”IdentityHashMap<K, V>
Throws
Section titled “Throws”IllegalArgumentException if expectedMaxSize is negative or NaN
Overrides
Section titled “Overrides”AbstractMap<K, V>.constructor
Constructor
Section titled “Constructor”new IdentityHashMap<
K,V>(map):IdentityHashMap<K,V>
Defined in: src/map/IdentityHashMap.ts:86
Creates a map with the mappings of map; keys that are distinct by reference stay distinct.
Parameters
Section titled “Parameters”Map<K, V>
Returns
Section titled “Returns”IdentityHashMap<K, V>
Throws
Section titled “Throws”NullPointerException if map is null or undefined
Overrides
Section titled “Overrides”AbstractMap<K, V>.constructor
Properties
Section titled “Properties”modCount
Section titled “modCount”modCount:
number=0
Defined in: src/map/IdentityHashMap.ts:70
Structural modification count; iterators compare against it.
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
Inherited from
Section titled “Inherited from”[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<[K,V]>
Defined in: src/map/IdentityHashMap.ts:224
Returns a fail-fast iterator over the mappings as [key, value] pairs, in unspecified order.
Returns
Section titled “Returns”IterableIterator<[K, V]>
Overrides
Section titled “Overrides”clear()
Section titled “clear()”clear():
void
Defined in: src/map/IdentityHashMap.ts:193
Removes all mappings.
Returns
Section titled “Returns”void
Overrides
Section titled “Overrides”clone()
Section titled “clone()”clone():
IdentityHashMap<K,V>
Defined in: src/map/IdentityHashMap.ts:95
Shallow copy of the same runtime class (subclass fields included).
Returns
Section titled “Returns”IdentityHashMap<K, V>
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
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”containsKey()
Section titled “containsKey()”containsKey(
key):boolean
Defined in: src/map/IdentityHashMap.ts:128
Returns true if this map has a mapping for key (compared by reference), even if it maps to null. O(1).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”containsValue()
Section titled “containsValue()”containsValue(
value):boolean
Defined in: src/map/IdentityHashMap.ts:133
Returns true if one or more keys map to value, compared by reference. O(n).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”entrySet()
Section titled “entrySet()”entrySet():
Set<MapEntry<K,V>>
Defined in: src/map/IdentityHashMap.ts:218
Returns a live view of the mappings. Its entries compare key and value by reference and setValue writes through;
removing from it removes the mapping, and it does not support add (UnsupportedOperationException).
Returns
Section titled “Returns”Set<MapEntry<K, V>>
Overrides
Section titled “Overrides”equals()
Section titled “equals()”equals(
o):boolean
Defined in: src/map/IdentityHashMap.ts:243
Returns true if o is a map with the same mappings, keys and values both compared by reference.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”forEach()
Section titled “forEach()”forEach(
action):void
Defined in: src/map/IdentityHashMap.ts:233
Calls action for each mapping, in iteration 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
Throws
Section titled “Throws”ConcurrentModificationException if action structurally modifies this map
Overrides
Section titled “Overrides”get(
key):V|null
Defined in: src/map/IdentityHashMap.ts:122
Returns the value mapped to key, or null if there is none (or the key maps to null). O(1); key is found by
reference, so an equal but distinct object is not found.
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”V | null
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”hashCode()
Section titled “hashCode()”hashCode():
number
Defined in: src/map/IdentityHashMap.ts:260
Returns the sum over all entries of the key’s identity hash code XOR the value’s hashCode(), in 32-bit
arithmetic, so it is consistent with reference equality.
Returns
Section titled “Returns”number
Overrides
Section titled “Overrides”isEmpty()
Section titled “isEmpty()”isEmpty():
boolean
Defined in: src/map/IdentityHashMap.ts:110
Returns true if this map has no mappings. O(1).
Returns
Section titled “Returns”boolean
Overrides
Section titled “Overrides”keySet()
Section titled “keySet()”keySet():
Set<K>
Defined in: src/map/IdentityHashMap.ts:202
Returns a live view of the keys, compared by reference. Removing from it removes the mapping; it does not support
add (UnsupportedOperationException).
Returns
Section titled “Returns”Set<K>
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”put(
key,value):V|null
Defined in: src/map/IdentityHashMap.ts:143
Maps key to value, replacing any previous value. O(1). A key that is not === to an existing key adds a new
mapping, even if it equals() one.
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”V | null
the previous value, or null if there was no mapping
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”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
Inherited from
Section titled “Inherited from”remove()
Section titled “remove()”Call Signature
Section titled “Call Signature”remove(
key):V|null
Defined in: src/map/IdentityHashMap.ts:155
Removes the mapping for key (compared by reference), if present. O(1).
Parameters
Section titled “Parameters”unknown
Returns
Section titled “Returns”V | null
the removed value, or null if there was no mapping
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”remove(
key,value):boolean
Defined in: src/map/IdentityHashMap.ts:160
Removes the mapping for key only if it is currently mapped to value, both compared by reference. O(1).
Parameters
Section titled “Parameters”unknown
unknown
Returns
Section titled “Returns”boolean
true if the mapping was removed
Overrides
Section titled “Overrides”replace()
Section titled “replace()”Call Signature
Section titled “Call Signature”replace(
key,value):V|null
Defined in: src/map/IdentityHashMap.ts:175
Replaces the value for key (compared by reference) only if key currently has a mapping (even to null). O(1).
Parameters
Section titled “Parameters”K
V
Returns
Section titled “Returns”V | null
the previous value, or null if there was no mapping
Overrides
Section titled “Overrides”Call Signature
Section titled “Call Signature”replace(
key,oldValue,newValue):boolean
Defined in: src/map/IdentityHashMap.ts:181
Replaces the value for key with newValue only if it is currently mapped to oldValue, both compared by
reference. O(1).
Parameters
Section titled “Parameters”K
oldValue
Section titled “oldValue”V
newValue
Section titled “newValue”V
Returns
Section titled “Returns”boolean
true if the value was replaced
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”size()
Section titled “size()”size():
number
Defined in: src/map/IdentityHashMap.ts:105
Returns the number of mappings. O(1).
Returns
Section titled “Returns”number
Overrides
Section titled “Overrides”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
Inherited from
Section titled “Inherited from”values()
Section titled “values()”values():
Collection<V>
Defined in: src/map/IdentityHashMap.ts:210
Returns a live view of the values; its contains and remove compare by reference. Removing from it removes the
mapping; it does not support add (UnsupportedOperationException).
Returns
Section titled “Returns”Collection<V>