Skip to main content
Module

x/rimbu/mod.ts>BiMap.Builder

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface BiMap.Builder
import { type BiMap } from "https://deno.land/x/rimbu@0.13.1/mod.ts";
const { Builder } = BiMap;

A mutable BiMap builder used to efficiently create new immutable instances. See the BiMap documentation and the BiMap.Builder API documentation

Properties

readonly
size: number

Returns the amount of entries in the builder.

readonly
isEmpty: boolean

Returns true if there are no entries in the builder.

Methods

getValue<UK = K>(key: RelatedTo<K, UK>): V | undefined

Returns the value associated with the given key, or given otherwise value if the key is not in the collection.

getValue<UK, O>(key: RelatedTo<K, UK>, otherwise: OptLazy<O>): V | O
getKey<UV = V>(value: RelatedTo<V, UV>): K | undefined

Returns the key associated with the given value, or given otherwise value if the value is not in the collection.

getKey<UV, O>(value: RelatedTo<V, UV>, otherwise: OptLazy<O>): K | O
hasKey<UK = K>(key: RelatedTo<K, UK>): boolean

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

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

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

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

Associates given key with given value in the builder.

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

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

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

Adds given entries to the builder.

removeKey<UK = K>(key: RelatedTo<K, UK>): V | undefined

Removes the entries related to given key from the builder.

removeKey<UK, O>(key: RelatedTo<K, UK>, otherwise: OptLazy<O>): V | O
removeKeys<UK = K>(keys: StreamSource<RelatedTo<K, UK>>): boolean

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

removeValue<UV = V>(value: RelatedTo<V, UV>): K | undefined

Removes the entries related to given value from the builder.

removeValue<UV, O>(value: RelatedTo<V, UV>, otherwise: OptLazy<O>): K | O
removeValues<UV = V>(values: StreamSource<RelatedTo<V, UV>>): boolean

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

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

Performs given function f for each entry of the builder.

build(): BiMap<K, V>

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