interface BiMultiMapBase.Builder<K,V,Tp>
undocumented
Implemented by: BiMultiMapBuilder<K,V,Tp,TpG>
Type parameters
| Name | Constraints | Default | Description |
|---|---|---|---|
| K | undocumented | ||
| V | undocumented | ||
| Tp | BiMultiMapBase.Types | BiMultiMapBase.Types | undocumented |
Properties
isEmpty
Returns true if there are no entries in the builder.
isEmptyDefinition
readonly isEmpty: boolean;
HashBiMultiMap.of([[1, 'a'], [2, 'b']]).toBuilder().isEmpty
// => false
size
Returns the amount of entries in the builder.
sizeDefinition
readonly size: number;
HashBiMultiMap.of([[1, 'a'], [2, 'b']]).toBuilder().size
// => 2
Methods
add
Associates given key with given value in the builder.
addkey with given value in the builder.addEntries
Adds given entries to the builder.
addEntriesentries to the builder.Definition
addEntries(entries: StreamSource<readonly [K, V]>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
entries | StreamSource<readonly [K, V]> |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.addEntries([1, 'a'], [3, 'c']]) // => true
m.addEntries([]) // => false
build
Returns an immutable collection instance containing the entries in this builder.
buildDefinition
build(): WithKeyValue<Tp, K, V>['normal'];
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
const m2: HashBiMultiMap<number, string> = m.build()
forEach
Performs given function f for each entry of the builder.
forEachf for each entry of the builder.Definition
forEach(f: (entry: [K, V], index: number, halt: () => void) => void, options?: {
state?: TraverseState;
}): void;
Parameters
| Name | Type | Description |
|---|---|---|
f | (entry: [K, V], index: number, halt: () => void) => void | the function to perform for each element, receiving: - entry: the next key-value entry- 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
HashBiMultiMap.of([1, 'a'], [2, 'b'], [3, 'c']).toBuilder().forEach((entry, i, halt) => {
console.log([entry[1], entry[0]]);
if (i >= 1) halt();
})
// => logs ['a', 1] ['b', 2]
O(N)
getKeys
Returns a collection representing the keys currently associated with given value.
getKeysvalue.Definition
getKeys<UV = V>(value: RelatedTo<V, UV>): WithKeyValue<Tp, K, V>['valueMultiMapValues'];
Type parameters
| Name | Default | Description |
|---|---|---|
| UV | V |
Parameters
| Name | Type | Description |
|---|---|---|
value | RelatedTo<V, UV> | the value for which to find the keys |
since it is unsafe to return the internal builder object, the result colleciton will be build upon each call to getKeys.
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.getKeys('a').toArray() // => [1]
m.getKeys('z').toArray() // => []
getValues
Returns a collection representing the values currently associated with given key.
getValueskey.Definition
getValues<UK = K>(key: RelatedTo<K, UK>): WithKeyValue<Tp, K, V>['keyMultiMapValues'];
Type parameters
| Name | Default | Description |
|---|---|---|
| UK | K |
Parameters
| Name | Type | Description |
|---|---|---|
key | RelatedTo<K, UK> | the key for which to find the values |
since it is unsafe to return the internal builder object, the result colleciton will be build upon each call to getValues.
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.getValues(1).toArray() // => ['a']
m.getValues(3).toArray() // => []
hasEntry
Returns true if the given key value entry is present in the builder.
hasEntrykey value entry is present in the builder.Definition
hasEntry<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 to look for |
value | RelatedTo<V, UV> | the value to look for |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.hasEntry(1, 'a') // => true
m.hasEntry(1, 'z') // => false
hasKey
Returns true if the given key is present in the builder.
hasKeykey is present in the builder.hasValue
Returns true if the given value is present in the builder.
hasValuevalue is present in the builder.removeEntries
Removes the entries in the given entries StreamSource from the builder.
removeEntriesentries StreamSource 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 = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeEntries([[1, 'c'], ['2', 'a']]) // => false
m.removeEntries([[1, 'a']]) // => true
removeEntry
Removes the entry of given key and value from the builder.
removeEntrykey and value 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 entry key |
value | RelatedTo<V, UV> |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeEntry(1, 'c') // => false
m.removeEntry(1, 'a') // => true
removeKey
Removes the entries related to given key from the builder.
removeKeykey from the builder.removeKeys
Removes the entries related to the given keys StreamSource from the builder.
removeKeyskeys StreamSource from the builder.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 = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeKeys([3, 4, 5]) // => false
m.removeKeys([1, 10]) // => true
removeValue
Removes the entries related to given value from the builder.
removeValuevalue from the builder.removeValues
Removes the entries related to the given values StreamSource from the builder.
removeValuesvalues StreamSource from the builder.Definition
removeValues<UV = V>(values: StreamSource<RelatedTo<V, UV>>): boolean;
Type parameters
| Name | Default | Description |
|---|---|---|
| UV | V |
Parameters
| Name | Type | Description |
|---|---|---|
values | StreamSource<RelatedTo<V, UV>> |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeValues(['c', 'd', 'e']) // => false
m.removeValues(['a', 'e']) // => true
setKeys
Sets the keys associated to given value to the keys in the given keys StreamSource.
setKeysvalue to the keys in the given keys StreamSource.Definition
setKeys(value: V, keys: StreamSource<K>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
value | V | the value to which to associate the keys |
keys | StreamSource<K> | a StreamSource containing the keys to associate to the value |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.setKeys('a', [3, 4]).getKeys('a').toArray() // => [3, 4]
setValues
Sets the values associated to given key to the values in the given values StreamSource.
setValueskey to the values in the given values StreamSource.Definition
setValues(key: K, values: StreamSource<V>): boolean;
Parameters
| Name | Type | Description |
|---|---|---|
key | K | the key to which to associate the values |
values | StreamSource<V> | a StreamSource containing the values to associate to the key |
const m = HashBiMultiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.setValues(1, ['b', 'c']).getValues(1).toArray() // => ['b', 'c']