class BiMapBuilder<K,V>
undocumented
Implements: BiMap.Builder<K,V>
Type parameters
Name | Description |
---|---|
K | undocumented |
V | undocumented |
Properties
_keyValueMap
undocumented
_keyValueMap
Definition
_keyValueMap?:
RMap.Builder
<K, V>;
_valueKeyMap
undocumented
_valueKeyMap
Definition
_valueKeyMap?:
RMap.Builder
<V, K>;
addEntries
undocumented
addEntries
Definition
addEntries: (source:
StreamSource
<readonly [K, V]>) => boolean;
context
undocumented
context
Definition
readonly context:
BiMapContext
<K, V>;
forEach
undocumented
forEach
Definition
forEach: (f: (entry: readonly [K, V], index: number, halt: () => void) => void, options?: {
state?:
TraverseState
;
}) => void;
getKey
undocumented
getKey
getValue
undocumented
getValue
isEmpty
undocumented
isEmpty
keyValueMap
undocumented
keyValueMap
Definition
get keyValueMap():
RMap.Builder
<K, V>;
removeKey
undocumented
removeKey
removeKeys
undocumented
removeKeys
Definition
removeKeys: <UK>(keys:
StreamSource
<
RelatedTo
<K, UK>>) => boolean;
removeValue
undocumented
removeValue
removeValues
undocumented
removeValues
Definition
removeValues: <UV>(values:
StreamSource
<
RelatedTo
<V, UV>>) => boolean;
size
undocumented
size
source
undocumented
source
Definition
source?:
BiMapNonEmptyImpl
<K, V>
|
undefined;
valueKeyMap
undocumented
valueKeyMap
Definition
get valueKeyMap():
RMap.Builder
<V, K>;
Methods
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 = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.addEntries([1, 'a'], [3, 'c']]) // => true
m.addEntries([]) // => false
Overrides
addEntry
Adds the given entry
to the builder, where the entry key is associated with the entry value.
addEntry
entry
to the builder, where the entry key is associated with the entry value.build
Returns an immutable collection instance containing the entries in this builder.
build
forEach
Performs given function f
for each entry of the builder.
forEach
f
for each entry of the builder.Definition
forEach(f: (entry: readonly [K, V], index: number, halt: () => void) => void, options?: {
state?:
TraverseState
;
}): void;
Parameters
Name | Type | Description |
---|---|---|
f | (entry: readonly [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 ; } | (optional) an object containing the following properties: - state: (optional) the traverse state |
RibuError.ModifiedBuilderWhileLoopingOverItError if the builder is modified while looping over it
BiMap.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)
Overrides
getKey
Returns the key associated with the given value
, or given otherwise
value if the value is not in the collection.
getKey
value
, or given otherwise
value if the value is not in the collection.Definitions
getKey<UV = V>(value:
RelatedTo
<V, UV>): K
|
undefined;
getKey<UV, O>(value:
RelatedTo
<V, UV>, otherwise:
OptLazy
<O>): K
|
O;
Type parameters
Name | Default | Description |
---|---|---|
UV | V |
Parameters
Name | Type | Description |
---|---|---|
value | RelatedTo <V, UV> | the value to look for |
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.getKey('b') // => 2
m.getKey('z') // => undefined
m.getKey('b', 'none') // => 2
m.getKey('z', 'none') // => 'none'
Overrides
getValue
Returns the value associated with the given key
, or given otherwise
value if the key is not in the collection.
getValue
key
, or given otherwise
value if the key is not in the collection.Definitions
getValue<UK = K>(key:
RelatedTo
<K, UK>): V
|
undefined;
getValue<UK, O>(key:
RelatedTo
<K, UK>, otherwise:
OptLazy
<O>): V
|
O;
Type parameters
Name | Default | Description |
---|---|---|
UK | K |
Parameters
Name | Type | Description |
---|---|---|
key | RelatedTo <K, UK> | the key to look for |
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.getValue(2) // => 'b'
m.getValue(3) // => undefined
m.getValue(2, 'none') // => 'b'
m.getValue(3, 'none') // => 'none'
Overrides
hasKey
Returns true if the given key
is present in the builder.
hasKey
key
is present in the builder.hasValue
Returns true if the given value
is present in the builder.
hasValue
value
is present in the builder.removeKey
Removes the entries related to given key
from the builder.
removeKey
key
from the builder.Definitions
removeKey<UK = K>(key:
RelatedTo
<K, UK>): V
|
undefined;
removeKey<UK, O>(key:
RelatedTo
<K, UK>, otherwise:
OptLazy
<O>): V
|
O;
Type parameters
Name | Default | Description |
---|---|---|
UK | K |
Parameters
Name | Type | Description |
---|---|---|
key | RelatedTo <K, UK> | the key to remove |
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeKey(2) // => 'b'
m.removeKey(3) // => undefined
m.removeKey(3, 'c') // => 'c'
Overrides
removeKeys
Removes the entries related to the given keys
StreamSource
from the builder.
removeKeys
keys
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 = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeKeys([3, 4, 5]) // => false
m.removeKeys([1, 10]) // => true
Overrides
removeValue
Removes the entries related to given value
from the builder.
removeValue
value
from the builder.Definitions
removeValue<UV = V>(value:
RelatedTo
<V, UV>): K
|
undefined;
removeValue<UV, O>(value:
RelatedTo
<V, UV>, otherwise:
OptLazy
<O>): K
|
O;
Type parameters
Name | Default | Description |
---|---|---|
UV | V |
Parameters
Name | Type | Description |
---|---|---|
value | RelatedTo <V, UV> | the value to remove |
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeValue('b') // => 2
m.removeValue('c') // => undefined
m.removeValue('c', 0) // => 0
Overrides
removeValues
Removes the entries related to the given values
StreamSource
from the builder.
removeValues
values
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 = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeValues(['c', 'd', 'e']) // => false
m.removeValues(['a', 'e']) // => true