Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/rimbu/multiset/custom/index.ts>MultiSetBase.Builder

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

Properties

readonly
size: number

Returns the amount of values in the builder.

readonly
sizeDistinct: number

Returns the amount of distinct values in the builder.

readonly
isEmpty: boolean

Returns true if there are no values in the builder.

Methods

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

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

add(value: T, amount?: number): boolean

Adds given value to the builder.

addAll(values: StreamSource<T>): boolean

Adds the values in given values StreamSource to the builder.

addEntries(entries: StreamSource<readonly [T, number]>): boolean

Adds for each tuple of a value and amount in the given entries, the amount of values to the builder.

remove<U = T>(value: RelatedTo<T, U>, amount?: number | "ALL"): number

Removes given amount or all of given value from the builder.

removeAllSingle<U = T>(values: StreamSource<RelatedTo<T, U>>): boolean

Removes every single value in given values from the builder.

removeAllEvery<U = T>(values: StreamSource<RelatedTo<T, U>>): boolean

Removes every instance of the given values from the builder.

setCount(value: T, amount: number): boolean

Sets the amount of given value in the collection to amount.

modifyCount(value: T, update: (currentCount: number) => number): boolean

Changes the amount of given value in the builder according to the result of given update function.

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

Returns the amount of given value in the builder.

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.

build(): WithElem<Tp, T>["normal"]

Returns an immutable instance containing the values in this builder.