Skip to content
Buy me a coffee

NavigableMap

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

A sorted map with navigation methods that return the closest match for a given key (each null when there is none) and range views with explicit inclusive flags. Entries returned by navigation methods are immutable snapshots. A null argument throws NullPointerException when the map rejects null keys.

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>

SortedMap.[iterator]


ceilingEntry(key): MapEntry<K, V> | null

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

Returns the entry with the least key greater than or equal to key (an immutable snapshot), or null.

K

MapEntry<K, V> | null


ceilingKey(key): K | null

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

Returns the least key greater than or equal to key, or null.

K

K | null


clear(): void

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

Removes all mappings.

void

UnsupportedOperationException if this map is unmodifiable

SortedMap.clear


comparator(): Comparator<K> | null

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

Returns the comparator that orders the keys, or null when natural ordering is used.

Comparator<K> | null

SortedMap.comparator


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)

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

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

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

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

SortedMap.containsValue


descendingKeySet(): NavigableSet<K>

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

Returns a live, descending view of the keys. Removing from it removes the mapping; add is not supported.

NavigableSet<K>


descendingMap(): NavigableMap<K, V>

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

Returns a live view of this map in descending key order: changes through either side are visible in the other.

NavigableMap<K, V>


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

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

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

SortedMap.firstEntry


firstKey(): K

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

Returns the lowest key.

K

NoSuchElementException if this map is empty

SortedMap.firstKey


floorEntry(key): MapEntry<K, V> | null

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

Returns the entry with the greatest key less than or equal to key (an immutable snapshot), or null.

K

MapEntry<K, V> | null


floorKey(key): K | null

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

Returns the greatest key less than or equal to key, or null.

K

K | 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

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

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

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

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

SortedMap.hashCode


headMap(toKey): SortedMap<K, V>

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

Returns a live view of the mappings whose keys are strictly less than toKey; same as headMap(toKey, false).

K

SortedMap<K, V>

IllegalArgumentException if this map is itself a range view and toKey is outside its range

SortedMap.headMap

headMap(toKey, inclusive): NavigableMap<K, V>

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

Returns a live view of the mappings whose keys are less than (or, if inclusive, equal to) toKey.

K

boolean

NavigableMap<K, V>

IllegalArgumentException if this map is itself a range view and toKey is outside its range

SortedMap.headMap


higherEntry(key): MapEntry<K, V> | null

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

Returns the entry with the least key strictly greater than key (an immutable snapshot), or null.

K

MapEntry<K, V> | null


higherKey(key): K | null

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

Returns the least key strictly greater than key, or null.

K

K | null


isEmpty(): boolean

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

Returns true if this map has no mappings.

boolean

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

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

SortedMap.lastEntry


lastKey(): K

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

Returns the highest key.

K

NoSuchElementException if this map is empty

SortedMap.lastKey


lowerEntry(key): MapEntry<K, V> | null

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

Returns the entry with the greatest key strictly less than key (an immutable snapshot), or null.

K

MapEntry<K, V> | null


lowerKey(key): K | null

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

Returns the greatest key strictly less than key, or null.

K

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

SortedMap.merge


navigableKeySet(): NavigableSet<K>

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

Returns a live, ascending view of the keys. Removing from it removes the mapping; add is not supported.

NavigableSet<K>


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

SortedMap.pollFirstEntry


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

SortedMap.pollLastEntry


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

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

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

SortedMap.putFirst


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

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

SortedMap.putLast


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

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

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

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

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

SortedMap.replaceAll


reversed(): NavigableMap<K, V>

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

Returns a live descending view; same as descendingMap().

NavigableMap<K, V>

SortedMap.reversed


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

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

Returns a live, sequenced view of the mappings.

SequencedSet<MapEntry<K, V>>

SortedMap.sequencedEntrySet


sequencedKeySet(): SequencedSet<K>

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

Returns a live, sequenced view of the keys.

SequencedSet<K>

SortedMap.sequencedKeySet


sequencedValues(): SequencedCollection<V>

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

Returns a live, sequenced view of the values.

SequencedCollection<V>

SortedMap.sequencedValues


size(): number

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

Returns the number of mappings.

number

SortedMap.size


subMap(fromKey, toKey): SortedMap<K, V>

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

Returns a live view of the mappings with keys from fromKey (inclusive) to toKey (exclusive); same as subMap(fromKey, true, toKey, false).

K

K

SortedMap<K, V>

IllegalArgumentException if fromKey is greater than toKey, or either is outside this view’s range

SortedMap.subMap

subMap(fromKey, fromInclusive, toKey, toInclusive): NavigableMap<K, V>

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

Returns a live view of the mappings with keys between fromKey and toKey, each end included when its flag is set.

K

boolean

K

boolean

NavigableMap<K, V>

IllegalArgumentException if fromKey is greater than toKey, or either is outside this view’s range

SortedMap.subMap


tailMap(fromKey): SortedMap<K, V>

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

Returns a live view of the mappings whose keys are greater than or equal to fromKey; same as tailMap(fromKey, true).

K

SortedMap<K, V>

IllegalArgumentException if this map is itself a range view and fromKey is outside its range

SortedMap.tailMap

tailMap(fromKey, inclusive): NavigableMap<K, V>

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

Returns a live view of the mappings whose keys are greater than (or, if inclusive, equal to) fromKey.

K

boolean

NavigableMap<K, V>

IllegalArgumentException if this map is itself a range view and fromKey is outside its range

SortedMap.tailMap


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

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

SortedMap.values