Skip to main content
Module

x/rimbu/mod.ts>SortedMap.NonEmpty

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
interface SortedMap.NonEmpty
implements [RMapBase.NonEmpty]<K, V, SortedMap.Types>, Omit<SortedMap<K, V>, keyof RMapBase.NonEmpty<any, any, any>>, [Streamable.NonEmpty]<readonly [K, V]>
import { type SortedMap } from "https://deno.land/x/rimbu@0.14.0/mod.ts";
const { NonEmpty } = SortedMap;

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

Examples

Example 1

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

Methods

stream(reversed?: boolean): Stream.NonEmpty<readonly [K, V]>
streamKeys(reversed?: boolean): Stream.NonEmpty<K>
streamValues(reversed?: boolean): Stream.NonEmpty<V>
min(): readonly [K, V]

Returns the entry with the minimum key of the SortedMap.

minKey(): K

Returns the minimum key of the SortedMap.

minValue(): V

Returns the value associated with the minimum key of the SortedMap.

max(): readonly [K, V]

Returns the entry with the maximum key of the SortedMap.

maxKey(): K

Returns the maximum key of the SortedMap.

maxValue(): V

Returns the value associated with the maximum key of the SortedMap.

take<N extends number>(amount: N): 0 extends N ? SortedMap<K, V> : SortedMap.NonEmpty<K, V>