콘텐츠로 이동
한국어

BidirectionalMap

이 콘텐츠는 아직 번역되지 않았습니다.

Defined in: src/util/BidirectionalMap.ts:57

K

V

  • Map<K, V>

new BidirectionalMap<K, V>(entries?): BidirectionalMap<K, V>

Defined in: src/util/BidirectionalMap.ts:73

Builds an empty map, or one seeded from entries the way new Map(…) seeds itself. Seeding goes through set, so a duplicate key or a duplicate value in the input resolves last-wins rather than corrupting the invariant.

Iterable<readonly [K, V], any, any> | null

BidirectionalMap<K, V>

get [toStringTag](): string

Defined in: src/util/BidirectionalMap.ts:294

Makes Object.prototype.toString.call(…) report [object BidirectionalMap].

string

Map.[toStringTag]


get size(): number

Defined in: src/util/BidirectionalMap.ts:82

Number of pairs. Both directions always agree on it.

number

Map.size

[iterator](): MapIterator<[K, V]>

Defined in: src/util/BidirectionalMap.ts:289

[key, value] pairs — makes the map spreadable and for…of-able.

MapIterator<[K, V]>

Map.[iterator]


clear(): void

Defined in: src/util/BidirectionalMap.ts:165

Drops every pair.

void

Map.clear


delete(key): boolean

Defined in: src/util/BidirectionalMap.ts:147

Removes the pair held by key, from both directions. true if there was one.

K

boolean

Map.delete


deleteValue(value): boolean

Defined in: src/util/BidirectionalMap.ts:156

Removes the pair held by value, from both directions. true if there was one.

V

boolean


entries(): MapIterator<[K, V]>

Defined in: src/util/BidirectionalMap.ts:183

[key, value] pairs, in insertion order.

MapIterator<[K, V]>

Map.entries


forEach(callback, thisArg?): void

Defined in: src/util/BidirectionalMap.ts:178

Iterates in insertion order, like Map.forEach.

The third callback argument is this map, not the internal forward one. Handing out the internal map would let a callback mutate one direction directly and leave the other stale — the invariant has to be unreachable from outside, not merely undocumented.

(value, key, map) => void

unknown

void

Map.forEach


get(key): V | undefined

Defined in: src/util/BidirectionalMap.ts:123

The value bound to key, or undefined.

K

V | undefined

Map.get


getKey(value): K | undefined

Defined in: src/util/BidirectionalMap.ts:132

The key bound to value, or undefined — the whole point of the type. Matches by SameValueZero, so two structurally equal objects are two different values.

V

K | undefined


getOrInsert(key, defaultValue): V

Defined in: src/util/BidirectionalMap.ts:219

The value bound to key, inserting defaultValue first if there is none. Inserting goes through set, so it can displace whichever key held defaultValue before.

K

V

V


getOrInsertComputed(key, callback): V

Defined in: src/util/BidirectionalMap.ts:229

The value bound to key, computing and inserting one if there is none. callback runs at most once, and only on the inserting path.

K

(key) => V

V


getOrInsertComputedKey(value, callback): K

Defined in: src/util/BidirectionalMap.ts:252

The key bound to value, computing and inserting one if there is none. callback runs at most once — it typically mints an identifier, so calling it twice would hand back one that was never stored.

V

(value) => K

K


getOrInsertKey(value, defaultKey): K

Defined in: src/util/BidirectionalMap.ts:241

The key bound to value, inserting defaultKey first if there is none. The mirror of getOrInsert — note it returns a key, not a value.

V

K

K


has(key): boolean

Defined in: src/util/BidirectionalMap.ts:137

Whether key is bound. Distinguishes “bound to undefined” from “absent”.

K

boolean

Map.has


hasValue(value): boolean

Defined in: src/util/BidirectionalMap.ts:142

Whether value is bound. Matches by SameValueZero, like getKey.

V

boolean


inverse(): BidirectionalMap<V, K>

Defined in: src/util/BidirectionalMap.ts:207

The same map, read the other way round — a view over the same storage, not a copy. A write on either side is visible from the other, and inverse().inverse() is another view with the original orientation.

BidirectionalMap<V, K>


keys(): MapIterator<K>

Defined in: src/util/BidirectionalMap.ts:188

The keys, in insertion order.

MapIterator<K>

Map.keys


reverseEntries(): MapIterator<[V, K]>

Defined in: src/util/BidirectionalMap.ts:198

[value, key] pairs — the reverse direction, in its own insertion order.

MapIterator<[V, K]>


set(key, value): this

Defined in: src/util/BidirectionalMap.ts:91

Binds key to value, evicting whatever held either side before — see the note on displacement in the class docs. Use BidirectionalMap.trySet to refuse instead of evicting.

K

V

this

Map.set


toJSON(): BidirectionalMapJson<K, V>

Defined in: src/util/BidirectionalMap.ts:265

Wire shape — the forward pairs only, tagged so a decoder can tell what it is. Honoured by JSON.stringify, which is what carries the map over the cluster wire; persistence stores use the richer JsonTree tag instead and never reach this method.

BidirectionalMapJson<K, V>


trySet(key, value): boolean

Defined in: src/util/BidirectionalMap.ts:111

Binds key to value only when that removes nothing: false — and no mutation at all — if either side is already bound to something else. Re-writing a pair that is already present is a no-op and returns true.

K

V

boolean


values(): MapIterator<V>

Defined in: src/util/BidirectionalMap.ts:193

The values, in insertion order. Every one is unique, so this is a set.

MapIterator<V>

Map.values


static fromJSON<K, V>(json): BidirectionalMap<K, V>

Defined in: src/util/BidirectionalMap.ts:278

Rebuilds a map from toJSON output, restoring the reverse direction from the forward pairs.

The payload is an array of pairs rather than an object, which is why this decoder needs none of the __proto__ guards a peer-facing object decoder does: keys go into a Map, where '__proto__' is an ordinary key and reaches no prototype setter.

K

V

BidirectionalMapJson<K, V>

BidirectionalMap<K, V>