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

x/rimbu/sorted/mod.ts>SortedMap

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

Interfaces

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

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

A non-empty type-invariant immutable Map of key type K, and value type V. In the Map, each key has exactly one value, and the Map cannot contain duplicate keys. See the Map documentation and the SortedMap API documentation

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

interface SortedMap
implements RMapBase<K, V, SortedMap.Types>
import { type SortedMap } from "https://deno.land/x/rimbu@1.0.3/sorted/mod.ts";

A type-invariant immutable Map of key type K, and value type V. In the Map, each key has exactly one value, and the Map cannot contain duplicate keys. See the Map documentation and the SortedMap API documentation

Examples

Example 1

const m1 = SortedMap.empty<number, string>()
const m2 = SortedMap.of([1, 'a'], [2, 'b'])

Methods

stream(reversed?: boolean): Stream<readonly [K, V]>
streamKeys(reversed?: boolean): Stream<K>
streamValues(reversed?: boolean): Stream<V>
streamRange(keyRange: Range<K>, reversed?: boolean): Stream<readonly [K, V]>

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

streamSliceIndex(range: IndexRange, reversed?: boolean): Stream<readonly [K, V]>

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

min(): readonly [K, V] | undefined

Returns the entry with the minimum key of the SortedMap, or a fallback value (default: undefined) if the SortedMap is empty.

min<O>(otherwise: OptLazy<O>): readonly [K, V] | O
minKey(): K | undefined

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

minKey<O>(otherwise: OptLazy<O>): K | O
minValue(): V | undefined

Returns the value associated with the minimum key of the SortedMap, or a fallback value (default: undefined) if the SortedMap is empty.

minValue<O>(otherwise: OptLazy<O>): V | O
max(): readonly [K, V] | undefined

Returns the entry with the maximum key of the SortedMap, or a fallback value (default: undefined) if the SortedMap is empty.

max<O>(otherwise: OptLazy<O>): readonly [K, V] | O
maxKey(): K | undefined

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

maxKey<O>(otherwise: OptLazy<O>): K | O
maxValue(): V | undefined

Returns the value associated with the maximum key of the SortedMap, or a fallback value (default: undefined) if the SortedMap is empty.

maxValue<O>(otherwise: OptLazy<O>): V | O
getAtIndex(index: number): readonly [K, V] | undefined

Returns the entry with its key at the given index of the key sort order of the SortedMap, or a fallback value (default: undefined) if the index is out of bounds.

getAtIndex<O>(index: number, otherwise: OptLazy<O>): readonly [K, V] | O
getKeyAtIndex(index: number): K | undefined

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

getKeyAtIndex<O>(index: number, otherwise: OptLazy<O>): K | O
getValueAtIndex(index: number): V | undefined

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

getValueAtIndex<O>(index: number, otherwise: OptLazy<O>): V | O
take(amount: number): SortedMap<K, V>

Returns a SortedMap containing the the first amount of elements of this SortedMap.

drop(amount: number): SortedMap<K, V>

Returns a SortedMap containing all but the the first amount of elements of this SortedMap.

sliceIndex(range: IndexRange): SortedMap<K, V>

Returns a SortedMap containing only those entries that are within the given range index range of they key sort order.

slice(keyRange: Range<K>): SortedMap<K, V>

Returns a SortedMap containing only those entries whose keys are within the given keyRange.

variable SortedMap
import { SortedMap } from "https://deno.land/x/rimbu@1.0.3/sorted/mod.ts";