跳转到内容
简体中文

BidirectionalMultiMap

此内容尚不支持你的语言。

Defined in: src/util/BidirectionalMultiMap.ts:83

L

R

new BidirectionalMultiMap<L, R>(pairs?): BidirectionalMultiMap<L, R>

Defined in: src/util/BidirectionalMultiMap.ts:100

Builds an empty relation, or one seeded from pairs. Seeding goes through add, so a repeated pair in the input is idempotent rather than counted twice.

Iterable<readonly [L, R], any, any> | null

BidirectionalMultiMap<L, R>

get [toStringTag](): string

Defined in: src/util/BidirectionalMultiMap.ts:333

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

string


get leftSize(): number

Defined in: src/util/BidirectionalMultiMap.ts:122

How many distinct left participants there are — every one of them holding at least one partner, since an empty participant cannot exist here.

O(1): the size of the forward map, not a walk over it. Correct on an inverse view for free, because the view’s forward map is this reverse one — so unlike PairCounter there is nothing to share.

number


get rightSize(): number

Defined in: src/util/BidirectionalMultiMap.ts:127

How many distinct right participants there are — the mirror of leftSize.

number


get size(): number

Defined in: src/util/BidirectionalMultiMap.ts:110

Number of pairs — not participants. Both directions always agree on it.

number

[iterator](): IterableIterator<[L, R]>

Defined in: src/util/BidirectionalMultiMap.ts:328

Every pair as [left, right] — makes the relation spreadable and for…of-able.

IterableIterator<[L, R]>


add(left, right): this

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

Relates left and right. Adding a pair that already exists is a no-op.

L

R

this


clear(): void

Defined in: src/util/BidirectionalMultiMap.ts:237

Drops every pair.

void


delete(left, right): boolean

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

Removes one pair from both directions. true if there was one.

A participant left with no partners is removed outright — see the note on participants in the class docs.

L

R

boolean


deleteLeft(left): boolean

Defined in: src/util/BidirectionalMultiMap.ts:192

Drops left and every pair it held — the Terminated case, where one participant stops and has to leave no trace on the other side. true if it held anything.

L

boolean


deleteRight(right): boolean

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

Drops right and every pair it held — the mirror of deleteLeft.

R

boolean


entries(): IterableIterator<[L, R]>

Defined in: src/util/BidirectionalMultiMap.ts:254

Every pair as [left, right], grouped by left participant in insertion order.

IterableIterator<[L, R]>


forEach(callback, thisArg?): void

Defined in: src/util/BidirectionalMultiMap.ts:268

Runs callback for every pair.

The third argument is this map, not an internal one. Handing out the storage would let a callback mutate one direction directly and leave the other stale — the same reasoning as the 1:1 sibling’s forEach.

(right, left, map) => void

unknown

void


get(left): ReadonlySet<R>

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

Everything left is related to — the live set, in insertion order. Empty when left has no partners, never undefined, so a caller can iterate the result without a guard.

L

ReadonlySet<R>


getKeys(right): ReadonlySet<L>

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

Everything related to right — the mirror of get, and the whole point of the type.

R

ReadonlySet<L>


has(left, right): boolean

Defined in: src/util/BidirectionalMultiMap.ts:222

Whether the pair is present.

L

R

boolean


hasLeft(left): boolean

Defined in: src/util/BidirectionalMultiMap.ts:227

Whether left has at least one partner.

L

boolean


hasRight(right): boolean

Defined in: src/util/BidirectionalMultiMap.ts:232

Whether right has at least one partner.

R

boolean


inverse(): BidirectionalMultiMap<R, L>

Defined in: src/util/BidirectionalMultiMap.ts:281

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

BidirectionalMultiMap<R, L>


lefts(): MapIterator<L>

Defined in: src/util/BidirectionalMultiMap.ts:244

The left participants, in insertion order. Every one has at least one partner.

MapIterator<L>


rights(): MapIterator<R>

Defined in: src/util/BidirectionalMultiMap.ts:249

The right participants, in insertion order. Every one has at least one partner.

MapIterator<R>


toJSON(): BidirectionalMultiMapJson<L, R>

Defined in: src/util/BidirectionalMultiMap.ts:295

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

BidirectionalMultiMapJson<L, R>


static fromJSON<L, R>(json): BidirectionalMultiMap<L, R>

Defined in: src/util/BidirectionalMultiMap.ts:310

Rebuilds a relation from toJSON output, restoring the reverse direction from the forward rows.

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

L

R

BidirectionalMultiMapJson<L, R>

BidirectionalMultiMap<L, R>