class MultiMapBuilder<K,V,Tp,TpG>
undocumented
Implements: MultiMapBase.Builder<K,V,Tp>
Type parameters
Name | Constraints | Default | Description |
---|---|---|---|
K | undocumented | ||
V | undocumented | ||
Tp | ContextImplTypes | undocumented | |
TpG | WithKeyValue <Tp, K, V> | WithKeyValue <Tp, K, V> | undocumented |
Properties
_keyMap
undocumented
_keyMap
Definition
_keyMap?:
RMap.Builder
<K,
RSet.Builder
<V>>;
addEntries
undocumented
addEntries
Definition
addEntries: (source:
StreamSource
<readonly [K, V]>) => boolean;
forEach
undocumented
forEach
Definition
forEach: (f: (entry: [K, V], index: number, halt: () => void) => void, options?: {
reversed?: boolean;
state?:
TraverseState
;
}) => void;
isEmpty
undocumented
isEmpty
keyMap
undocumented
keyMap
Definition
get keyMap():
RMap.Builder
<K,
RSet.Builder
<V>>;
removeEntries
undocumented
removeEntries
Definition
removeEntries: <UK, UV>(entries:
StreamSource
<[
RelatedTo
<K, UK>,
RelatedTo
<V, UV>]>) => boolean;
removeEntry
undocumented
removeEntry
removeKeys
undocumented
removeKeys
Definition
removeKeys: <UK>(keys:
StreamSource
<
RelatedTo
<K, UK>>) => boolean;
setValues
undocumented
setValues
Definition
setValues: (key: K, source:
StreamSource
<V>) => boolean;
size
undocumented
size
source
undocumented
source
Definition
source?:
MultiMap.NonEmpty
<K, V>
|
undefined;
Methods
add
Adds an entry with given key
and value
to the builder.
add
key
and value
to the builder.addEntries
Adds given entries
to the builder.
addEntries
entries
to the builder.Definition
addEntries(entries:
StreamSource
<readonly [K, V]>): boolean;
Parameters
Name | Type | Description |
---|---|---|
entries | StreamSource <readonly [K, V]> |
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.addEntries([1, 'a'], [2, 'b']]) // => false
m.addEntries([1, 'b'], [2, 'd']]) // => true
Overrides
build
Returns an immutable collection instance containing the entries in this builder.
build
Definition
build():
WithKeyValue
<Tp, K, V>['normal'];
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
const m2: HashMultiMapHashValue<number, string> = m.build()
Overrides
forEach
Performs given function f
for each entry of the builder, using given state
as initial traversal state.
forEach
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
Name | Type | Description |
---|---|---|
f | (entry: [K, V], index: number, value: () => void) => void | the 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 ; } |
RibuError.ModifiedBuilderWhileLoopingOverItError if the builder is modified while looping over it
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)
O(N)
Overrides
getValues
Returns a built immutable collection of the values asssociated with given key
getValues
key
Definition
getValues<UK = K>(key:
RelatedTo
<K, UK>):
WithKeyValue
<Tp, K, V>['keyMapValues'];
Type parameters
Name | Default | Description |
---|---|---|
UK | K |
Parameters
Name | Type | Description |
---|---|---|
key | RelatedTo <K, UK> | the key for which to get the associated values |
const m = HashMultiMapHashValue.of([[1, 'a'], [2, 'b'], [1, 'c']]).toBuilder()
m.getValues(1).toArray() // => ['a', 'c']
m.getValues(10).toArray() // => []
Overrides
hasEntry
Returns true if the given value
is associated with given key
in the builder.
hasEntry
value
is associated with given key
in the builder.Definition
hasEntry<UK = K>(key:
RelatedTo
<K, UK>, value: V): boolean;
Type parameters
Name | Default | Description |
---|---|---|
UK | K |
Parameters
Name | Type | Description |
---|---|---|
key | RelatedTo <K, UK> | the key to look for |
value | V | the value to look for |
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
hasKey
Returns true if the given key
is present in the builder.
hasKey
key
is present in the builder.removeEntries
Removes the given entries
from the builder.
removeEntries
entries
from the builder.Definition
removeEntries<UK = K, UV = V>(entries:
StreamSource
<[
RelatedTo
<K, UK>,
RelatedTo
<V, UV>]>): boolean;
Type parameters
Name | Default | Description |
---|---|---|
UK | K | |
UV | V |
Parameters
Name | Type | Description |
---|---|---|
entries | StreamSource <[ RelatedTo <K, UK>, RelatedTo <V, UV>]> |
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.removeEntries([[3, 'a'], [3, 'b']]) // => false
m.removeEntries([[1, 'a'], [3, 'b']]) // => true
Overrides
removeEntry
Removes the given value
from the values associated with given key
from the builder.
removeEntry
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
Name | Default | Description |
---|---|---|
UK | K | |
UV | V |
Parameters
Name | Type | Description |
---|---|---|
key | RelatedTo <K, UK> | the key at which to remove the value |
value | RelatedTo <V, UV> |
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder()
m.removeEntry(3, 'a') // => false
m.removeEntry(1, 'a') // => true
Overrides
removeKey
Removes the values associated with given key
from the builder.
removeKey
key
from the builder.removeKeys
Removes the values associated with each key of the given keys
removeKeys
keys
Definition
removeKeys<UK = K>(keys:
StreamSource
<
RelatedTo
<K, UK>>): boolean;
Type parameters
Name | Default | Description |
---|---|---|
UK | K |
Parameters
Name | Type | Description |
---|---|---|
keys | StreamSource < RelatedTo <K, UK>> |
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b'], [1, 'c']).toBuilder()
m.removeKeys([10, 11]) // => false
m.removeKeys([1]) // => true
Overrides
setValues
Returns true if the data in the builder has changed
setValues
Definition
setValues(key: K, values:
StreamSource
<V>): boolean;
Parameters
Name | Type | Description |
---|---|---|
key | K | |
values | StreamSource <V> |
const m = HashMultiMapHashValue.of([1, 'a'], [2, 'b']).toBuilder()
m.setValues(1, ['a']) // => false
m.setValues(2, ['c', 'd']) // => true