Skip to main content

class BiMapBuilder<K,V>

undocumented

Implements: BiMap.Builder<K,V>

Type parameters

NameDescription
Kundocumented
Vundocumented

Properties

_keyValueMap

undocumented

Definition

_keyValueMap?: RMap.Builder<K, V>;

_lock

undocumented

Definition

_lock: number;

_valueKeyMap

undocumented

Definition

_valueKeyMap?: RMap.Builder<V, K>;

addEntries

undocumented

Definition

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

addEntry

undocumented

Definition

addEntry: (entry: readonly [K, V]) => boolean;

build

undocumented

Definition

build: () => BiMap<K, V>;

context

undocumented

Definition

readonly context: BiMapContext<K, V>;

forEach

undocumented

Definition

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

getKey

undocumented

Definition

getKey: <UV, O>(value: RelatedTo<V, UV>, otherwise?: OptLazy<O> |undefined) => K| O;

getValue

undocumented

Definition

getValue: <UK, O>(key: RelatedTo<K, UK>, otherwise?: OptLazy<O> |undefined) => V| O;

hasKey

undocumented

Definition

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

hasValue

undocumented

Definition

hasValue: <UV>(value: RelatedTo<V, UV>) => boolean;

isEmpty

undocumented

Definition

get isEmpty(): boolean;

Overrides

Builder.isEmpty

keyValueMap

undocumented

Definition

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

removeKey

undocumented

Definition

removeKey: <UK, O>(key: RelatedTo<K, UK>, otherwise?: OptLazy<O> |undefined) => V| O;

removeKeys

undocumented

Definition

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

removeValue

undocumented

Definition

removeValue: <UV, O>(value: RelatedTo<V, UV>, otherwise?: OptLazy<O> |undefined) => K| O;

removeValues

undocumented

Definition

removeValues: <UV>(values: StreamSource<RelatedTo<V, UV>>) => boolean;

set

undocumented

Definition

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

size

undocumented

Definition

get size(): number;

Overrides

Builder.size

source

undocumented

Definition

source?: BiMapNonEmptyImpl<K, V> | undefined;

valueKeyMap

undocumented

Definition

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

Methods

addEntries

Adds given entries to the builder.

Definition

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

Parameters

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

Overrides

Builder.addEntries

addEntry

Adds the given entry to the builder, where the entry key is associated with the entry value.

Definition

addEntry(entry: readonly [K, V]): boolean;

Parameters

NameTypeDescription
entryreadonly [K, V]
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.addEntry([1, 'a']) // => false
m.addEntry([1, 'b']) // => true

Overrides

Builder.addEntry

build

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

Definition

build(): BiMap<K, V>;

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

Overrides

Builder.build

checkLock

undocumented

Definition

checkLock(): void;

forEach

Performs given function f for each entry of the builder.

Definition

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

Parameters

NameTypeDescription
f(entry: readonly [K, V], index: number, halt: () => void) => voidthe 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
throws

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

example
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]
note

O(N)

Overrides

Builder.forEach

getKey

Returns the key associated with the given 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

NameDefaultDescription
UVV

Parameters

NameTypeDescription
valueRelatedTo<V, UV>the value to look for
example
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

Builder.getKey

getValue

Returns the value associated with the given 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

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key to look for
example
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

Builder.getValue

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 = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.hasKey(2) // => true
m.hasKey(3) // => false

Overrides

Builder.hasKey

hasValue

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

Definition

hasValue<UV = V>(value: RelatedTo<V, UV>): boolean;

Type parameters

NameDefaultDescription
UVV

Parameters

NameTypeDescription
valueRelatedTo<V, UV>the value to look for
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.hasValue('a') // => true
m.hasValue('z') // => false

Overrides

Builder.hasValue

removeKey

Removes the entries related to given 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

NameDefaultDescription
UKK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>the key to remove
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeKey(2) // => 'b'
m.removeKey(3) // => undefined
m.removeKey(3, 'c') // => 'c'

Overrides

Builder.removeKey

removeKeys

Removes the entries related to the given keys StreamSource from the builder.

Definition

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

Type parameters

NameDefaultDescription
UKK

Parameters

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

Overrides

Builder.removeKeys

removeValue

Removes the entries related to given 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

NameDefaultDescription
UVV

Parameters

NameTypeDescription
valueRelatedTo<V, UV>the value to remove
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeValue('b') // => 2
m.removeValue('c') // => undefined
m.removeValue('c', 0) // => 0

Overrides

Builder.removeValue

removeValues

Removes the entries related to the given values StreamSource from the builder.

Definition

removeValues<UV = V>(values: StreamSource<RelatedTo<V, UV>>): boolean;

Type parameters

NameDefaultDescription
UVV

Parameters

NameTypeDescription
valuesStreamSource<RelatedTo<V, UV>>
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.removeValues(['c', 'd', 'e']) // => false
m.removeValues(['a', 'e']) // => true

Overrides

Builder.removeValues

set

Associates given key with given value in the builder.

Definition

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

Parameters

NameTypeDescription
keyKthe entry key
valueV
example
const m = BiMap.of([1, 'a'], [2, 'b']).toBuilder()
m.set(1, 'a') // => false
m.set(1, 'b') // => true

Overrides

Builder.set