Skip to main content

interface SortedMap.NonEmpty<K,V>

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

Type parameters​

NameDescription
Kthe key type
Vthe value type
note
  • The SortedMap keeps the inserted keys in sorted order according to the context's comp instance.
example
const m1 = SortedMap.empty<number, string>()
const m2 = SortedMap.of([1, 'a'], [2, 'b'])

Methods​

max​

Returns the entry with the maximum key of the SortedMap.

Definition​

max(): readonly [K, V];

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.max())
// => ['d', 4]

maxKey​

Returns the maximum key of the SortedMap.

Definition​

maxKey(): K;

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.maxKey())
// => 'd'

maxValue​

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

Definition​

maxValue(): V;

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.maxValue())
// => 4

min​

Returns the entry with the minimum key of the SortedMap.

Definition​

min(): readonly [K, V];

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]);
console.log(m.min())
// => ['a', 1]

minKey​

Returns the minimum key of the SortedMap.

Definition​

minKey(): K;

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]);
console.log(m.minKey())
// => 'a'

minValue​

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

Definition​

minValue(): V;

example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.minValue())
// => 1

stream​

undocumented

Definition​

stream(options?: {
      reversed?: boolean;
    }): Stream.NonEmpty<readonly [K, V]>;

Parameters​

NameTypeDescription
options{
      reversed?: boolean;
    }

streamKeys​

undocumented

Definition​

streamKeys(options?: {
      reversed?: boolean;
    }): Stream.NonEmpty<K>;

Parameters​

NameTypeDescription
options{
      reversed?: boolean;
    }

streamValues​

undocumented

Definition​

streamValues(options?: {
      reversed?: boolean;
    }): Stream.NonEmpty<V>;

Parameters​

NameTypeDescription
options{
      reversed?: boolean;
    }

take​

undocumented

Definition​

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

Type parameters​

NameConstraintsDescription
Nnumber

Parameters​

NameTypeDescription
amountN