Skip to main content

class SortedMapEmpty<K,V>

undocumented

Implements: SortedMap<K,V>

Type parameters

NameDefaultDescription
Kanyundocumented
Vanyundocumented

Properties

_NonEmptyType

undocumented

Definition

_NonEmptyType: SortedMap.NonEmpty<K, V>;

context

undocumented

Definition

readonly context: SortedMapContext<K>;

Methods

addEntries

undocumented

Definition

addEntries(entries: StreamSource<readonly [K, V]>): SortedMap.NonEmpty<K, V>;

Parameters

NameTypeDescription
entriesStreamSource<readonly [K, V]>

addEntry

undocumented

Definition

addEntry(entry: readonly [K, V]): SortedMap.NonEmpty<K, V>;

Parameters

NameTypeDescription
entryreadonly [K, V]

drop

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

Definition

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

Parameters

NameTypeDescription
amountnumberthe amount of elements to drop
note

a negative amount drops the last elements instead of the first, e.g. -2 is the last 2 elements

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

Overrides

SortedMap.drop

get

undocumented

Definition

get<_, O>(key: any, otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
_
O

Parameters

NameTypeDescription
keyany
otherwiseOptLazy<O>

getAtIndex

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.

Definitions

getAtIndex(index: number): readonly [K, V] | undefined;

getAtIndex<O>(index: number, otherwise: OptLazy<O>): readonly [K, V] | 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 m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.getAtIndex(1))
// => ['b', 2]
console.log(m.getAtIndex(-1))
// => ['d', 4]
console.log(m.getAtIndex(10))
// => undefined
console.log(m.getAtIndex(10, 'q'))
// => 'q'

Overrides

SortedMap.getAtIndex

getKeyAtIndex

undocumented

Definition

getKeyAtIndex<O>(index: number, otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
indexnumber
otherwiseOptLazy<O>

Overrides

SortedMap.getKeyAtIndex

getValueAtIndex

undocumented

Definition

getValueAtIndex<O>(index: number, otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
indexnumber
otherwiseOptLazy<O>

Overrides

SortedMap.getValueAtIndex

hasKey

undocumented

Definition

hasKey(): false;

mapValues

undocumented

Definition

mapValues<V2>(): SortedMap<K, V2>;

Type parameters

NameDescription
V2

max

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

Definitions

max(): readonly [K, V] | undefined;

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

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

Overrides

SortedMap.max

maxKey

undocumented

Definition

maxKey<O>(otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
otherwiseOptLazy<O>

Overrides

SortedMap.maxKey

maxValue

undocumented

Definition

maxValue<O>(otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
otherwiseOptLazy<O>

Overrides

SortedMap.maxValue

min

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

Definitions

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

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

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

Overrides

SortedMap.min

minKey

undocumented

Definition

minKey<O>(otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
otherwiseOptLazy<O>

Overrides

SortedMap.minKey

minValue

undocumented

Definition

minValue<O>(otherwise?: OptLazy<O>): O;

Type parameters

NameDescription
O

Parameters

NameTypeDescription
otherwiseOptLazy<O>

Overrides

SortedMap.minValue

modifyAt

undocumented

Definition

modifyAt(atKey: K, options: {
    ifNew?: OptLazyOr<V, Token>;
  }): SortedMap<K, V>;

Parameters

NameTypeDescription
atKeyK
options{
    ifNew?: OptLazyOr<V, Token>;
  }

removeKey

undocumented

Definition

removeKey(): SortedMap<K, V>;

removeKeyAndGet

undocumented

Definition

removeKeyAndGet(): undefined;

removeKeys

undocumented

Definition

removeKeys(): SortedMap<K, V>;

set

undocumented

Definition

set(key: K, value: V): SortedMap.NonEmpty<K, V>;

Parameters

NameTypeDescription
keyK
valueV

slice

undocumented

Definition

slice(): SortedMap<K, V>;

Overrides

SortedMap.slice

sliceIndex

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

Definition

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

Parameters

NameTypeDescription
rangeIndexRangean IndexRange defining the sort order indices to include.
example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.sliceIndex({ start: 1, amount: 2 }).toArray())
// => [['b', 2], ['c', 3]]

Overrides

SortedMap.sliceIndex

stream

undocumented

Definition

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

Parameters

NameTypeDescription
options{
    reversed?: boolean;
  }

Overrides

SortedMap.stream

streamKeys

undocumented

Definition

streamKeys(): Stream<K>;

Overrides

SortedMap.streamKeys

streamRange

undocumented

Definition

streamRange(): Stream<readonly [K, V]>;

Overrides

SortedMap.streamRange

streamSliceIndex

undocumented

Definition

streamSliceIndex(): Stream<readonly [K, V]>;

Overrides

SortedMap.streamSliceIndex

streamValues

undocumented

Definition

streamValues(): Stream<V>;

Overrides

SortedMap.streamValues

take

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

Definition

take(amount: number): SortedMap<K, V>;

Parameters

NameTypeDescription
amountnumberthe amount of elements to keep
note

a negative amount takes the last elements instead of the first, e.g. -2 is the last 2 elements

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

Overrides

SortedMap.take

toBuilder

undocumented

Definition

toBuilder(): SortedMapBuilder<K, V>;

toJSON

undocumented

Definition

toJSON(): ToJSON<any[]>;

toString

undocumented

Definition

toString(): string;

updateAt

undocumented

Definition

updateAt(): SortedMap<K, V>;