Skip to main content

class ContextBase<UT,Tp>

undocumented

Implements: RSetBase.Context<UT,Tp>

Extended by: OrderedSetContextImpl<UT,Tp>, SortedSetContext<UT>, HashSetContext<UT>

Type parameters

NameConstraintsDefaultDescription
UTundocumented
TpRSetBase.TypesRSetBase.Typesundocumented

Properties

_empty

undocumented

Definition

abstract get _empty(): (Tp & Elem<any>)['normal'];

_fixedElementType

undocumented

Definition

readonly _fixedElementType: any;

Overrides

Context._fixedElementType

_types

undocumented

Definition

get _types(): Tp;

Overrides

Context._types

empty

undocumented

Definition

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

from

undocumented

Definition

readonly from: any;

of

undocumented

Definition

readonly of: <T extends UT>(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

abstract get typeTag(): string;

Overrides

Context.typeTag

Methods

builder

undocumented

Definition

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

Type parameters

NameConstraintsDescription
TUT

Overrides

Factory.builder

empty

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

Definition

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

Type parameters

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

Overrides

Factory.empty

from

Returns an immutable set of this collection type and context, containing the given values in source.

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>>an array of StreamSource instances containing values
example
HashSet.from([1, 2, 3], [4, 5])   // => HashSet.NonEmpty<number>

Overrides

Factory.from

isNonEmptyInstance

undocumented

Definition

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

Type parameters

NameDescription
T

Parameters

NameTypeDescription
sourceany

isValidValue

undocumented

Definition

abstract isValidValue(value: any): value is UT;

Parameters

NameTypeDescription
valueany

Overrides

Context.isValidValue

of

Returns an immutable set of this 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 values
example
HashSet.of(1, 2, 3).toArray()   // => [1, 2, 3]

Overrides

Factory.of

reducer

Returns a Reducer that appends received items to an RSet and returns the RSet as a result. When a source is given, the reducer will first create an RSet from the source, and then append 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 append to
example
const someList = SortedSet.of(1, 2, 3);
const result = Stream.range({ start: 20, amount: 5 }).reduce(SortedSet.reducer(someList))
result.toArray() // => [1, 2, 3, 20, 21, 22, 23, 24]
note

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

Overrides

Factory.reducer