Skip to main content

class MultiMapBuilder<K,V,Tp,TpG>

undocumented

Implements: MultiMapBase.Builder<K,V,Tp>

Type parameters

NameConstraintsDefaultDescription
Kundocumented
Vundocumented
TpContextImplTypesundocumented
TpGWithKeyValue<Tp, K, V>WithKeyValue<Tp, K, V>undocumented

Properties

_keyMap

undocumented

Definition

_keyMap?: RMap.Builder<K, RSet.Builder<V>>;

_lock

undocumented

Definition

_lock: number;

_size

undocumented

Definition

_size: number;

add

undocumented

Definition

add: (key: K, value: V) => boolean;

addEntries

undocumented

Definition

addEntries: (source: StreamSource<readonly [K, V]>) => boolean;

build

undocumented

Definition

build: () => TpG['normal'];

context

undocumented

Definition

readonly context: TpG['context'];

forEach

undocumented

Definition

forEach: (f: (entry: [K, V], index: number, halt: () => void) => void, options?: {
    reversed?: boolean;
    state?: TraverseState;
  }) => void;

getValues

undocumented

Definition

getValues: <UK>(key: RelatedTo<K, UK>) => any;

hasEntry

undocumented

Definition

hasEntry: <UK>(key: RelatedTo<K, UK>, value: V) => boolean;

hasKey

undocumented

Definition

hasKey: <UK>(key: RelatedTo<K, UK>) => boolean;

isEmpty

undocumented

Definition

get isEmpty(): boolean;

Overrides

Builder.isEmpty

keyMap

undocumented

Definition

get keyMap(): RMap.Builder<K, RSet.Builder<V>>;

removeEntries

undocumented

Definition

removeEntries: <UK, UV>(entries: StreamSource<[RelatedTo<K, UK>, RelatedTo<V, UV>]>) => boolean;

removeEntry

undocumented

Definition

removeEntry: <UK, UV>(key: RelatedTo<K, UK>, value: RelatedTo<V, UV>) => boolean;

removeKey

undocumented

Definition

removeKey: <UK>(key: RelatedTo<K, UK>) => boolean;

removeKeys

undocumented

Definition

removeKeys: <UK>(keys: StreamSource<RelatedTo<K, UK>>) => boolean;

setValues

undocumented

Definition

setValues: (key: K, source: StreamSource<V>) => boolean;

size

undocumented

Definition

get size(): number;

Overrides

Builder.size

source

undocumented

Definition

source?: MultiMap.NonEmpty<K, V> | undefined;

Methods

add

Adds an entry with given key and value to the builder.

Definition

add(key: K, value: V): boolean;

Parameters

NameTypeDescription
keyKthe entry key
valueV

Overrides

Builder.add

addEntries

Adds given entries to the builder.

Definition

addEntries(entries: StreamSource<readonly [K, V]>): boolean;

Parameters

NameTypeDescription
entriesStreamSource<readonly [K, V]>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.addEntries([1, 'a'], [2, 'b']]) // => false
m.addEntries([1, 'b'], [2, 'd']]) // => true

Overrides

Builder.addEntries

build

Returns an immutable collection instance containing the entries in this builder.

Definition

build(): WithKeyValue<Tp, K, V>['normal'];

example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
const m2: HashMultiMapHashValue<number, string> = m.build()

Overrides

Builder.build

checkLock

undocumented

Definition

checkLock(): void;

forEach

Performs given function f for each entry of the builder, using given state as initial traversal state.

Definition

forEach(f: (entry: [K, V], index: number, value: () => void) => void, options?: {
      state?: TraverseState;
    }): void;

Parameters

NameTypeDescription
f(entry: [K, V], index: number, value: () => void) => voidthe function to perform for each element, receiving:
- entry: the next tuple of a key and value
- index: the index of the element
- halt: a function that, if called, ensures that no new elements are passed
options{
      state?: TraverseState;
    }
throws

RibuError.ModifiedBuilderWhileLoopingOverItError if the builder is modified while looping over it

example
HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder().forEach((entry, i, halt) => {
console.log([entry[1], entry[0]]);
if (i >= 1) halt();
})
// => logs ['a', 1] ['c', 1] (or other order)
note

O(N)

Overrides

Builder.forEach

getValues

Returns a built immutable collection of the values asssociated with given key

Definition

getValues<UK = K>(key: RelatedTo<K, UK>): WithKeyValue<Tp, K, V>['keyMapValues'];

Type parameters

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key for which to get the associated values
example
const m = HashMultiMapHashValue.of([[1, 'a'], [2, 'b'], [1, 'c']]).toBuilder()
m.getValues(1).toArray() // => ['a', 'c']
m.getValues(10).toArray() // => []

Overrides

Builder.getValues

hasEntry

Returns true if the given value is associated with given key in the builder.

Definition

hasEntry<UK = K>(key: RelatedTo<K, UK>, value: V): boolean;

Type parameters

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key to look for
valueVthe value to look for
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.hasEntry(2, 'b') // => true
m.hasEntry(2, 'c') // => false
m.hasEntry(3, 'a') // => false

Overrides

Builder.hasEntry

hasKey

Returns true if the given key is present in the builder.

Definition

hasKey<UK = K>(key: RelatedTo<K, UK>): boolean;

Type parameters

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key to look for
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.hasKey(2) // => true
m.hasKey(3) // => false

Overrides

Builder.hasKey

removeEntries

Removes the given entries from the builder.

Definition

removeEntries<UK = K, UV = V>(entries: StreamSource<[RelatedTo<K, UK>, RelatedTo<V, UV>]>): boolean;

Type parameters

NameDefaultDescription
UKK
UVV

Parameters

NameTypeDescription
entriesStreamSource<[RelatedTo<K, UK>, RelatedTo<V, UV>]>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.removeEntries([[3, 'a'], [3, 'b']]) // => false
m.removeEntries([[1, 'a'], [3, 'b']]) // => true

Overrides

Builder.removeEntries

removeEntry

Removes the given value from the values associated with given key from the builder.

Definition

removeEntry<UK = K, UV = V>(key: RelatedTo<K, UK>, value: RelatedTo<V, UV>): boolean;

Type parameters

NameDefaultDescription
UKK
UVV

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key at which to remove the value
valueRelatedTo<V, UV>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder()
m.removeEntry(3, 'a') // => false
m.removeEntry(1, 'a') // => true

Overrides

Builder.removeEntry

removeKey

Removes the values associated with given key from the builder.

Definition

removeKey<UK = K>(key: RelatedTo<K, UK>): boolean;

Type parameters

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder()
m.removeKey(3) // => false
m.removeKey(1) // => true

Overrides

Builder.removeKey

removeKeys

Removes the values associated with each key of the given keys

Definition

removeKeys<UK = K>(keys: StreamSource<RelatedTo<K, UK>>): boolean;

Type parameters

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keysStreamSource<RelatedTo<K, UK>>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder()
m.removeKeys([10, 11]) // => false
m.removeKeys([1]) // => true

Overrides

Builder.removeKeys

setValues

Returns true if the data in the builder has changed

Definition

setValues(key: K, values: StreamSource<V>): boolean;

Parameters

NameTypeDescription
keyK
valuesStreamSource<V>
example
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.setValues(1, ['a']) // => false
m.setValues(2, ['c', 'd']) // => true

Overrides

Builder.setValues