Skip to main content

class MultiSetContext<UT,N,Tp>

undocumented

Implements: MultiSetBase.Context<UT,Tp>

Type parameters

NameConstraintsDefaultDescription
UTundocumented
Nstringundocumented
TpContextImplTypesContextImplTypesundocumented

Properties

_empty

undocumented

Definition

readonly _empty: WithElem<Tp, UT>['normal'];

_types

undocumented

Definition

get _types(): Tp;

Overrides

Context._types

builder

undocumented

Definition

readonly builder: <T extends UT>() => WithElem<Tp, T>["builder"];

countMapContext

undocumented

Definition

readonly countMapContext: (Tp & Elem<UT>)['countMapContext'];

Overrides

Context.countMapContext

empty

undocumented

Definition

readonly empty: <T extends UT>() => WithElem<Tp, T>["normal"];

from

undocumented

Definition

readonly from: any;

of

undocumented

Definition

readonly of: <T>(values_0: T, ...values_1: T[]) => T extends UT ? WithElem<Tp, T>["nonEmpty"] : never;

reducer

undocumented

Definition

readonly reducer: <T extends UT>(source?: StreamSource<T>) => Reducer<T, WithElem<Tp, T>["normal"]>;

typeTag

undocumented

Definition

readonly typeTag: N;

Overrides

Context.typeTag

Methods

builder

Returns an empty builder instance for this type of collection and context.

Definition

builder<T extends UT>(): WithElem<Tp, T>['builder'];

Type parameters

NameConstraintsDescription
TUT
example
HashMultiSet.builder<number>()    // => HashMultiSet.Builder<number>

Overrides

Factory.builder

createBuilder

undocumented

Definition

createBuilder<T extends UT>(source?: WithElem<Tp, T>['nonEmpty']): WithElem<Tp, T>['builder'];

Type parameters

NameConstraintsDescription
TUT

Parameters

NameTypeDescription
sourceWithElem<Tp, T>['nonEmpty']

createNonEmpty

undocumented

Definition

createNonEmpty<T extends UT>(countMap: WithElem<Tp, T>['countMapNonEmpty'], size: number): WithElem<Tp, T>['nonEmpty'];

Type parameters

NameConstraintsDescription
TUT

Parameters

NameTypeDescription
countMapWithElem<Tp, T>['countMapNonEmpty']
sizenumber

empty

Returns the (singleton) empty instance of this type and context with given key and value types.

Definition

empty<T extends UT>(): WithElem<Tp, T>['normal'];

Type parameters

NameConstraintsDescription
TUT
example
HashMultiSet.empty<number>()    // => HashMultiSet<number>
HashMultiSet.empty<string>() // => HashMultiSet<string>

Overrides

Factory.empty

from

Returns an immutable multimap of this type and context, containing the values in the given sources StreamSource.

Definitions

from<T extends UT>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<T>>): WithElem<Tp, T>['nonEmpty'];

from<T extends UT>(...sources: ArrayNonEmpty<StreamSource<T>>): WithElem<Tp, T>['normal'];

Type parameters

NameConstraintsDescription
TUT

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StreamSource.NonEmpty<T>>a non-empty array of StreamSource instances containing values to add
example
HashMultiSet.from([1, 2], [2, 3, 4]).toArray()    // => [1, 2, 2, 3, 4]

Overrides

Factory.from

isNonEmptyInstance

undocumented

Definition

isNonEmptyInstance<T>(source: any): source is WithElem<Tp, T>['nonEmpty'];

Type parameters

NameDescription
T

Parameters

NameTypeDescription
sourceany

isValidElem

undocumented

Definition

isValidElem(elem: any): elem is UT;

Parameters

NameTypeDescription
elemany

Overrides

Context.isValidElem

of

Returns an immutable multimap of this collection type and context, containing the given values.

Definition

of<T extends UT>(...values: ArrayNonEmpty<T>): WithElem<Tp, T>['nonEmpty'];

Type parameters

NameConstraintsDescription
TUT

Parameters

NameTypeDescription
valuesArrayNonEmpty<T>a non-empty array of vslues
example
HashMultiSet.of(1, 2, 2)    // => HashMultiSet.NonEmpty<number>

Overrides

Factory.of

reducer

Returns a Reducer that appends received items to a MultiSet and returns the MultiSet as a result. When a source is given, the reducer will first create a MultiSet from the source, and then add elements to it.

Definition

reducer<T extends UT>(source?: StreamSource<T>): Reducer<T, WithElem<Tp, T>['normal']>;

Type parameters

NameConstraintsDescription
TUT

Parameters

NameTypeDescription
sourceStreamSource<T>(optional) an initial source of elements to add to
example
const someList = [1, 2, 3];
const result = Stream.range({ start: 20, amount: 5 }).reduce(SortedMultiSet.reducer(someList))
result.toArray() // => [1, 2, 3, 20, 21, 22, 23, 24]
note

uses a MultiSet builder under the hood. If the given source is a MultiSet in the same context, it will directly call .toBuilder().

Overrides

Factory.reducer