Skip to main content

interface OrderedSortedSet.Builder<T>

A mutable OrderedSortedSet builder used to efficiently create new immutable instances. See the Set documentation and the OrderedSortedSet.Builder API documentation

Extends: OrderedSetBase.Builder<T,Tp>

Type parameters

NameDescription
Tthe value type

Properties

isEmpty

Returns true if there are no values in the builder.

Definition

readonly isEmpty: boolean;

example
HashSet.of(1, 2, 3).toBuilder().isEmpty
// => false

Overrides

Builder.isEmpty

size

Returns the amount of values in the builder.

Definition

readonly size: number;

example
HashSet.of(1, 2, 3).toBuilder().size
// => 3

Overrides

Builder.size

Methods

add

Adds given value to the builder.

Definition

add(value: T): boolean;

Parameters

NameTypeDescription
valueT
example
const s = HashSet.of(1, 2, 3).toBuilder()
s.add(2) // => false
s.add(10) // => true

Overrides

Builder.add

addAll

Adds the values in given values StreamSource to the builder.

Definition

addAll(values: StreamSource<T>): boolean;

Parameters

NameTypeDescription
valuesStreamSource<T>
example
const s = HashSet.of(1, 2, 3).toBuilder()
s.addAll([1, 3]) // => false
s.addAll([2, 10]) // => true

Overrides

Builder.addAll

build

Returns an immutable instance containing the values in this builder.

Definition

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

example
const s = HashSet.of(1, 2, 3).toBuilder()
const s2: HashSet<number> = m.build()

Overrides

Builder.build

forEach

Performs given function f for each value of the builder.

Definition

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

Parameters

NameTypeDescription
f(value: T, index: number, halt: () => void) => voidthe function to perform for each element, receiving:
- value: the next element
- index: the index of the element
- halt: a function that, if called, ensures that no new elements are passed
options{
      state?: TraverseState;
    }
(optional) an object containing the following properties:
- state: (optional) the traversal state
throws

RibuError.ModifiedBuilderWhileLoopingOverItError if the builder is modified while looping over it

example
HashSet.of(1, 2, 3).toBuilder.forEach((value, i, halt) => {
console.log([value, i]);
if (i >= 1) halt();
})
// => logs [1, 0] [2, 1]
note

O(N)

Overrides

Builder.forEach

has

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

Definition

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

Type parameters

NameDefaultDescription
UT

Parameters

NameTypeDescription
valueRelatedTo<T, U>the value to look for
example
const s = HashSet.of(1, 2, 3).toBuilder()
s.has(2) // => true
s.has(10) // => false

Overrides

Builder.has

remove

Remove the given value from the builder.

Definition

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

Type parameters

NameDefaultDescription
UT

Parameters

NameTypeDescription
valueRelatedTo<T, U>
example
const s = HashSet.of(1, 2, 3).toBuilder()
s.remove(10) // => false
s.remove(2) // => true

Overrides

Builder.remove

removeAll

Removes the values in given values StreamSource from this builder.

Definition

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

Type parameters

NameDefaultDescription
UT

Parameters

NameTypeDescription
valuesStreamSource<RelatedTo<T, U>>a StreamSource of values
example
const s = HashSet.of(1, 2, 3).toBuilder()
s.removeAll([1, 3]) // => false
s.removeAll([2, 10]) // => true

Overrides

Builder.removeAll