Skip to main content

interface SortedSet.Builder<T>

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

Type parameters​

NameDescription
Tthe value type

Methods​

getAtIndex​

Returns the value at the given index of the value sort order of the SortedSet builder, or a fallback value (default: undefined) if the index is out of bounds.

Definitions​

getAtIndex(index: number): T | undefined;

getAtIndex<O>(index: number, otherwise: OptLazy<O>): T | O;

Parameters​

NameTypeDescription
indexnumberthe index in the key sort order
note

negative index values will retrieve the values from the end of the sort order, e.g. -1 is the last value

example
const b = SortedSet.of('b', 'd', 'a', 'c').toBuilder();
console.log(b.getAtIndex(1))
// => 'b'
console.log(b.getAtIndex(-1))
// => 'd'
console.log(b.getAtIndex(10))
// => undefined
console.log(b.getAtIndex(10, 'q'))
// => 'q'

max​

Returns the maximum value of the SortedSet builder, or a fallback value (default: undefined) if the builder is empty.

Definitions​

max(): T | undefined;

max<O>(otherwise: OptLazy<O>): T | O;

example
const b = SortedSet.of('b', 'd', 'a', 'c').toBuilder();
console.log(b.max())
// => 'd'
console.log(b.max('q'))
// => 'd'
console.log(SortedSet.empty().max())
// => undefined
console.log(SortedSet.empty().max('q'))
// => 'q'

min​

Returns the minimum value of the SortedSet builder, or a fallback value (default: undefined) if the builder is empty.

Definitions​

min(): T | undefined;

min<O>(otherwise: OptLazy<O>): T | O;

example
const b = SortedSet.of('b', 'd', 'a', 'c').toBuilder();
console.log(b.min())
// => 'a'
console.log(b.min('q'))
// => 'a'
console.log(SortedSet.empty().min())
// => undefined
console.log(SortedSet.empty().min('q'))
// => 'q'