Skip to main content

class HashSetBlockBuilder<T>

undocumented

Implements: HashSet.Builder<T>

Type parameters

NameDescription
Tundocumented

Properties

_entries

undocumented

Definition

_entries?: undefined | T[];

_entrySets

undocumented

Definition

_entrySets?: undefined | SetBlockBuilderEntry<T>[];

_lock

undocumented

Definition

_lock: number;

add

undocumented

Definition

add: (value: T) => boolean;

addAll

undocumented

Definition

addAll: (source: StreamSource<T>) => boolean;

build

undocumented

Definition

build: () => HashSet<T>;

context

undocumented

Definition

readonly context: HashSetContext<T>;

entries

undocumented

Definition

get entries(): T[];

entrySets

undocumented

Definition

get entrySets(): SetBlockBuilderEntry<T>[];

forEach

undocumented

Definition

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

has

undocumented

Definition

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

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

level

undocumented

Definition

level: number;

remove

undocumented

Definition

remove: <ST>(value: ST) => boolean;

removeAll

undocumented

Definition

removeAll: <ST>(values: StreamSource<ST>) => boolean;

size

undocumented

Definition

size: number;

Overrides

Builder.size

source

undocumented

Definition

source?: undefined | HashSetBlock<T>;

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

addInternal

undocumented

Definition

addInternal(value: T, hash?: number): boolean;

Parameters

NameTypeDescription
valueT
hashnumber

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

buildNE

undocumented

Definition

buildNE(): HashSetBlock<T>;

checkLock

undocumented

Definition

checkLock(): void;

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

hasInternal

undocumented

Definition

hasInternal(value: T, hash?: number): boolean;

Parameters

NameTypeDescription
valueT
hashnumber

prepareMutate

undocumented

Definition

prepareMutate(): void;

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

removeInternal

undocumented

Definition

removeInternal(value: T, hash?: number): boolean;

Parameters

NameTypeDescription
valueT
hashnumber