Skip to main content
Module

x/rimbu/multiset/custom/index.ts>VariantMultiSetBase

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

Interfaces

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

interface VariantMultiSetBase
implements FastIterable<T>
import { type VariantMultiSetBase } from "https://deno.land/x/rimbu@1.2.1/multiset/custom/index.ts";

Properties

readonly
isEmpty: boolean

Returns true if the collection is empty.

readonly
size: number

Returns the number of values in the collection.

readonly
sizeDistinct: number

Returns the number of distinct values in the collection.

readonly
countMap: WithElem<Tp, T>["countMap"]

Returns the Map representation of this collection.

Methods

nonEmpty(): this is WithElem<Tp, T>["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.

assumeNonEmpty(): WithElem<Tp, T>["nonEmpty"]

Returns the collection as a .NonEmpty type

stream(): Stream<T>

Returns a Stream containing all values of this collection.

streamDistinct(): Stream<T>

Returns a Stream containing all distinct values of this collection.

remove<U = T>(value: RelatedTo<T, U>, options?: { amount?: number | "ALL"; }): WithElem<Tp, T>["normal"]

Returns the collection where the given amount (default: 'ALL') of the given value are removed.

removeAllSingle<U = T>(values: StreamSource<RelatedTo<T, U>>): WithElem<Tp, T>["normal"]

Returns the collection where every single value from given values StreamSource is removed.

removeAllEvery<U = T>(values: StreamSource<RelatedTo<T, U>>): WithElem<Tp, T>["normal"]

Returns the collection where for every value from given values StreamSource, all values in the collection are removed.

has<U = T>(value: RelatedTo<T, U>): boolean

Returns true if the given value exists in the collection.

count<U = T>(value: RelatedTo<T, U>): number

Returns the amount of occurrances of the given value in the collection.

forEach(f: (
value: T,
index: number,
halt: () => void,
) => void
, options?: { state?: TraverseState; }
): void

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

filterEntries<TF extends T>(pred: (entry: readonly [T, number], index: number) => entry is [TF, number], options?: { negate?: false | undefined; }): WithElem<Tp, TF>["normal"]

Returns the collection containing only those values for which the given pred function returns true.

filterEntries<TF extends T>(pred: (entry: readonly [T, number], index: number) => entry is [TF, number], options: { negate: true; }): WithElem<Tp, Exclude<T, TF>>["normal"]
filterEntries(pred: (entry: readonly [T, number], index: number) => boolean, options?: { negate?: boolean; }): WithElem<Tp, T>["normal"]
toArray(): T[]

Returns an array containing all values in this collection.

toString(): string

Returns a string representation of this collection.

toJSON(): ToJSON<(readonly [T, number])[]>

Returns a JSON representation of this collection.