Skip to main content
Module

x/rimbu/multimap/custom/index.ts>VariantMultiMapBase

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Latest
namespace VariantMultiMapBase
import { VariantMultiMapBase } from "https://deno.land/x/rimbu@1.2.1/multimap/custom/index.ts";

Interfaces

Utility interface that provides higher-kinded types for this collection.

interface VariantMultiMapBase
implements FastIterable<[K, V]>
import { type VariantMultiMapBase } from "https://deno.land/x/rimbu@1.2.1/multimap/custom/index.ts";

Properties

readonly
isEmpty: boolean

Returns true if the collection is empty.

readonly
keySize: number

Returns the number of keys in the collection.

readonly
size: number

Returns the number of unique key-value combinations in this collection.

readonly
keyMap: WithKeyValue<Tp, K, V>["keyMap"]

Returns the Map representation of this collection.

Methods

assumeNonEmpty(): WithKeyValue<Tp, K, V>["nonEmpty"]

Returns the collection as a .NonEmpty type

nonEmpty(): this is WithKeyValue<Tp, K, V>["nonEmpty"]

Returns true if there is at least one entry in the collection, and instructs the compiler to treat the collection as a .NonEmpty type.

stream(): Stream<[K, V]>

Returns a Stream containing all entries of this collection as tuples of key and value.

streamKeys(): Stream<K>

Returns a Stream containing all keys of this collection.

streamValues(): Stream<V>

Returns a Stream containing all values of this collection.

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

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

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

Returns true if the given key has the given value as one of its values in the collection.

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

Returns the value collection associated to the given key.

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

Returns the collection where the values associated with given key are removed.

removeKeys<UK = K>(keys: StreamSource<RelatedTo<K, UK>>): WithKeyValue<Tp, K, V>["normal"]

Returns the collection where the values associated with given keys are removed.

removeEntry<UK = K, UV = V>(key: RelatedTo<K, UK>, value: RelatedTo<V, UV>): WithKeyValue<Tp, K, V>["normal"]

Returns the collection where given value if removed from the values associated with given key.

removeEntries<UK = K, UV = V>(entries: StreamSource<[RelatedTo<K, UK>, RelatedTo<V, UV>]>): WithKeyValue<Tp, K, V>["normal"]

Returns the collection where given entries are removed.

removeKeyAndGet<UK = K>(key: RelatedTo<K, UK>): [WithKeyValue<Tp, K, V>["normal"], WithKeyValue<Tp, K, V>["keyMapValuesNonEmpty"]] | undefined

Returns a tuple containing the collection of which the given key is removed, and the values that are associated with that key. If the key is not present, it will return undefined instead.

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

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

filter(pred: (
entry: [K, V],
index: number,
halt: () => void,
) => boolean
, options?: { negate?: boolean; }
): WithKeyValue<Tp, K, V>["normal"]

Returns a collection containing only those entries that satisfy given pred predicate.

toArray(): [K, V][]

Returns an array containing all entries in this collection.

toString(): string

Returns a string representation of this collection.

toJSON(): ToJSON<[K, V[]][]>

Returns a JSON representation of this collection.