interface MultiMapBase.Builder<K,V,Tp>
undocumented
Implemented by: MultiMapBuilder<K,V,Tp,TpG>
, HashMultiMapHashValue.Builder<K,V>
, SortedMultiMapSortedValue.Builder<K,V>
, MultiMap.Builder<K,V>
, SortedMultiMapHashValue.Builder<K,V>
, HashMultiMapSortedValue.Builder<K,V>
Type parameters
Name | Constraints | Default | Description |
---|---|---|---|
K | undocumented | ||
V | undocumented | ||
Tp | MultiMapBase.Types | MultiMapBase.Types | undocumented |
Properties
isEmpty
Returns true if there are no entries in the builder.
isEmpty
Definition
readonly isEmpty: boolean;
HashMultiMapHashValue.of([[1, 'a'], [2, 'b']]).toBuilder().isEmpty
// => false
size
Returns the amount of entries in the builder.
size
Definition
readonly size: number;
HashMultiMapHashValue.of([[1, 'a'], [2, 'b'], [1, 'c']]).toBuilder().size
// => 3
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
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()
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)
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() // => []
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
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
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
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
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