Skip to main content
Module

x/rimbu/multimap/custom/index.ts>MultiMapBase.Builder

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

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

getValues<UK = K>(key: RelatedTo<K, UK>): WithKeyValue<Tp, K, V>["keyMapValues"]

Returns a built immutable collection of the values asssociated with given key

setValues(key: K, values: StreamSource<V>): boolean

Assigns given values StreamSource to the given key, replacing potential existing values, and removing the key if values is empty.

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

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

hasEntry<UK = K>(key: RelatedTo<K, UK>, value: V): boolean

Returns true if the given value is associated with given key in the builder.

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

Adds an entry with given key and value to the builder.

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

Adds given entries to the builder.

removeEntry<UK = K, UV = V>(key: RelatedTo<K, UK>, value: RelatedTo<V, UV>): boolean

Removes the given value from the values associated with given key from the builder.

removeEntries<UK = K, UV = V>(entries: StreamSource<[RelatedTo<K, UK>, RelatedTo<V, UV>]>): boolean

Removes the given entries from the builder.

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

Removes the values associated with given key from the builder.

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

Removes the values associated with each key of the given keys

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

Performs given function f for each entry of the builder, using given state as initial traversal state.

build(): WithKeyValue<Tp, K, V>["normal"]

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