BidirectionalMultiMap
Este conteúdo não está disponível em sua língua ainda.
Defined in: src/util/BidirectionalMultiMap.ts:80
Type Parameters
Section titled “Type Parameters”L
R
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BidirectionalMultiMap<
L,R>(pairs?):BidirectionalMultiMap<L,R>
Defined in: src/util/BidirectionalMultiMap.ts:97
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.
Parameters
Section titled “Parameters”pairs?
Section titled “pairs?”Iterable<readonly [L, R], any, any> | null
Returns
Section titled “Returns”BidirectionalMultiMap<L, R>
Accessors
Section titled “Accessors”[toStringTag]
Section titled “[toStringTag]”Get Signature
Section titled “Get Signature”get [toStringTag]():
string
Defined in: src/util/BidirectionalMultiMap.ts:313
Makes Object.prototype.toString.call(…) report [object BidirectionalMultiMap].
Returns
Section titled “Returns”string
Get Signature
Section titled “Get Signature”get size():
number
Defined in: src/util/BidirectionalMultiMap.ts:107
Number of pairs — not participants. Both directions always agree on it.
Returns
Section titled “Returns”number
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
IterableIterator<[L,R]>
Defined in: src/util/BidirectionalMultiMap.ts:308
Every pair as [left, right] — makes the relation spreadable and for…of-able.
Returns
Section titled “Returns”IterableIterator<[L, R]>
add(
left,right):this
Defined in: src/util/BidirectionalMultiMap.ts:112
Relates left and right. Adding a pair that already exists is a no-op.
Parameters
Section titled “Parameters”L
R
Returns
Section titled “Returns”this
clear()
Section titled “clear()”clear():
void
Defined in: src/util/BidirectionalMultiMap.ts:217
Drops every pair.
Returns
Section titled “Returns”void
delete()
Section titled “delete()”delete(
left,right):boolean
Defined in: src/util/BidirectionalMultiMap.ts:136
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.
Parameters
Section titled “Parameters”L
R
Returns
Section titled “Returns”boolean
deleteLeft()
Section titled “deleteLeft()”deleteLeft(
left):boolean
Defined in: src/util/BidirectionalMultiMap.ts:172
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.
Parameters
Section titled “Parameters”L
Returns
Section titled “Returns”boolean
deleteRight()
Section titled “deleteRight()”deleteRight(
right):boolean
Defined in: src/util/BidirectionalMultiMap.ts:187
Drops right and every pair it held — the mirror of deleteLeft.
Parameters
Section titled “Parameters”R
Returns
Section titled “Returns”boolean
entries()
Section titled “entries()”entries():
IterableIterator<[L,R]>
Defined in: src/util/BidirectionalMultiMap.ts:234
Every pair as [left, right], grouped by left participant in insertion order.
Returns
Section titled “Returns”IterableIterator<[L, R]>
forEach()
Section titled “forEach()”forEach(
callback,thisArg?):void
Defined in: src/util/BidirectionalMultiMap.ts:248
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.
Parameters
Section titled “Parameters”callback
Section titled “callback”(right, left, map) => void
thisArg?
Section titled “thisArg?”unknown
Returns
Section titled “Returns”void
get(
left):ReadonlySet<R>
Defined in: src/util/BidirectionalMultiMap.ts:158
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.
Parameters
Section titled “Parameters”L
Returns
Section titled “Returns”ReadonlySet<R>
getKeys()
Section titled “getKeys()”getKeys(
right):ReadonlySet<L>
Defined in: src/util/BidirectionalMultiMap.ts:163
Everything related to right — the mirror of get, and the whole point of the type.
Parameters
Section titled “Parameters”R
Returns
Section titled “Returns”ReadonlySet<L>
has(
left,right):boolean
Defined in: src/util/BidirectionalMultiMap.ts:202
Whether the pair is present.
Parameters
Section titled “Parameters”L
R
Returns
Section titled “Returns”boolean
hasLeft()
Section titled “hasLeft()”hasLeft(
left):boolean
Defined in: src/util/BidirectionalMultiMap.ts:207
Whether left has at least one partner.
Parameters
Section titled “Parameters”L
Returns
Section titled “Returns”boolean
hasRight()
Section titled “hasRight()”hasRight(
right):boolean
Defined in: src/util/BidirectionalMultiMap.ts:212
Whether right has at least one partner.
Parameters
Section titled “Parameters”R
Returns
Section titled “Returns”boolean
inverse()
Section titled “inverse()”inverse():
BidirectionalMultiMap<R,L>
Defined in: src/util/BidirectionalMultiMap.ts:261
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.
Returns
Section titled “Returns”BidirectionalMultiMap<R, L>
lefts()
Section titled “lefts()”lefts():
MapIterator<L>
Defined in: src/util/BidirectionalMultiMap.ts:224
The left participants, in insertion order. Every one has at least one partner.
Returns
Section titled “Returns”MapIterator<L>
rights()
Section titled “rights()”rights():
MapIterator<R>
Defined in: src/util/BidirectionalMultiMap.ts:229
The right participants, in insertion order. Every one has at least one partner.
Returns
Section titled “Returns”MapIterator<R>
toJSON()
Section titled “toJSON()”toJSON():
BidirectionalMultiMapJson<L,R>
Defined in: src/util/BidirectionalMultiMap.ts:275
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.
Returns
Section titled “Returns”BidirectionalMultiMapJson<L, R>
fromJSON()
Section titled “fromJSON()”
staticfromJSON<L,R>(json):BidirectionalMultiMap<L,R>
Defined in: src/util/BidirectionalMultiMap.ts:290
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.
Type Parameters
Section titled “Type Parameters”L
R
Parameters
Section titled “Parameters”BidirectionalMultiMapJson<L, R>
Returns
Section titled “Returns”BidirectionalMultiMap<L, R>
