Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/rimbu/sorted/main/index.ts>SortedSet

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
namespace SortedSet
import { SortedSet } from "https://deno.land/x/rimbu@1.0.2/sorted/main/index.ts";

Interfaces

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

A context instance for a SortedSet that acts as a factory for every instance of this type of collection.

A non-empty type-invariant immutable Set of value type T. In the Set, there are no duplicate values. See the Set documentation and the SortedSet API documentation

Utility interface that provides higher-kinded types for this collection.

interface SortedSet
implements RSetBase<T, SortedSet.Types>
import { type SortedSet } from "https://deno.land/x/rimbu@1.0.2/sorted/main/index.ts";

A type-invariant immutable Set of value type T. In the Set, there are no duplicate values. See the Set documentation and the SortedSet API documentation

Examples

Example 1

const s1 = SortedSet.empty<string>()
const s2 = SortedSet.of('a', 'b', 'c')

Methods

stream(reversed?: boolean): Stream<T>
streamRange(range: Range<T>, reversed?: boolean): Stream<T>

Returns a Stream of sorted values of this collection within the given keyRange.

streamSliceIndex(range: IndexRange, reversed?: boolean): Stream<T>

Returns a Stream of sorted values of this collection within the given range index range.

min(): T | undefined

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

min<O>(otherwise: OptLazy<O>): T | O
max(): T | undefined

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

max<O>(otherwise: OptLazy<O>): T | O
getAtIndex(index: number): T | undefined

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

getAtIndex<O>(index: number, otherwise: OptLazy<O>): T | O
take(amount: number): SortedSet<T>

Returns a SortedSet containing the the first amount of value of this SortedSet.

drop(amount: number): SortedSet<T>

Returns a SortedSet containing all but the the first amount of value of this SortedSet.

sliceIndex(range: IndexRange): SortedSet<T>

Returns a SortedSet containing only those values that are within the given range index range of the value sort order.

slice(range: Range<T>): SortedSet<T>

Returns a SortedSet containing only those values that are within the given keyRange.

variable SortedSet
import { SortedSet } from "https://deno.land/x/rimbu@1.0.2/sorted/main/index.ts";