Skip to main content

class SortedMapLeaf<K,V>

undocumented

Extends: SortedMapNode<K,V>

Type parameters

NameDescription
Kundocumented
Vundocumented

Properties

context

undocumented

Definition

readonly context: SortedMapContext<K>;

Overrides

SortedMapNode.context

entries

undocumented

Definition

entries: readonly (readonly [K, V])[];

isEmpty

Returns false since this collection is known to be non-empty.

Definition

readonly isEmpty: false;

example
HashMap.of([1, 1], [2, 2]).isEmpty   // => false

Overrides

VariantMapBase.isEmptyNonEmpty.isEmpty

size

undocumented

Definition

get size(): number;

Overrides

SortedMapNode.size

Methods

[Symbol.iterator]

Returns a FastIterator instance used to iterate over the values of this Iterable.

Definition

[Symbol.iterator](): FastIterator<T>;

Overrides

FastIterable.[Symbol.iterator]

addEntries

Returns the collection with the entries from the given StreamSource entries added.

Definition

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

Parameters

NameTypeDescription
entriesStreamSource<readonly [K, V]>
example
HashMap.of([1, 'a']).addEntries([[2, 'b']]).toArray()   // => [[1, 'a'], [2, 'b']]

Overrides

NonEmpty.addEntries, SortedMapNode.addEntries

addEntry

Returns the collection with given entry added.

Definition

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

Parameters

NameTypeDescription
entryreadonly [K, V]
example
HashMap.of([1, 'a']).addEntry([2, 'b']).toArray()   // => [[1, 'a'], [2, 'b']]
HashMap.of([1, 'a']).addEntry([1, 'b']).toArray() // => [[1, 'b']]

Overrides

RMapBase.addEntry, SortedMapNode.addEntry

addInternal

undocumented

Definition

addInternal(entry: readonly [K, V]): SortedMapNode<K, V>;

Parameters

NameTypeDescription
entryreadonly [K, V]

Overrides

SortedMapNode.addInternal

asNormal

undocumented

Definition

asNormal(): this;

Overrides

SortedMapNode.asNormal

assumeNonEmpty

Returns a self reference since this collection is known to be non-empty.

Definition

assumeNonEmpty(): this;

example
const m = HashMap.of([1, 1], [2, 2]);
m === m.assumeNonEmpty() // => true

Overrides

VariantMapBase.assumeNonEmpty, NonEmpty.assumeNonEmpty

copy

undocumented

Definition

copy(entries: readonly (readonly [K, V])[]): SortedMapLeaf<K, V>;

Parameters

NameTypeDescription
entriesreadonly (readonly [K, V])[]

deleteMax

undocumented

Definition

deleteMax(): [readonly [K, V], SortedMapLeaf<K, V>];

deleteMin

undocumented

Definition

deleteMin(): [readonly [K, V], SortedMapLeaf<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
amountnumber
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, SortedMapNode.drop

dropInternal

undocumented

Definition

dropInternal(amount: number): SortedMapLeaf<K, V>;

Parameters

NameTypeDescription
amountnumber

filter

undocumented

Definition

filter(pred: (entry: readonly [K, V], index: number, halt: () => void) => boolean, options?: {
    negate?: boolean;
  }): SortedMap<K, V>;

Parameters

NameTypeDescription
pred(entry: readonly [K, V], index: number, halt: () => void) => boolean
options{
    negate?: boolean;
  }

Overrides

SortedMapNode.filter

forEach

undocumented

Definition

forEach(f: (entry: readonly [K, V], index: number, halt: () => void) => void, options?: {
    state?: TraverseState;
  }): void;

Parameters

NameTypeDescription
f(entry: readonly [K, V], index: number, halt: () => void) => void
options{
    state?: TraverseState;
  }

Overrides

SortedMapNode.forEach

get

undocumented

Definition

get<UK, O>(key: RelatedTo<K, UK>, otherwise?: OptLazy<O>): V | O;

Type parameters

NameDescription
UK
O

Parameters

NameTypeDescription
keyRelatedTo<K, UK>
otherwiseOptLazy<O>

Overrides

SortedMapNode.get

getAtIndex

undocumented

Definition

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

Type parameters

NameDescription
O

Parameters

NameTypeDescription
indexnumber
otherwiseOptLazy<O>

Overrides

SortedMap.getAtIndex

getInsertIndexOf

undocumented

Definition

getInsertIndexOf(key: K): number;

Parameters

NameTypeDescription
keyK

Overrides

SortedMapNode.getInsertIndexOf

getKeyAtIndex

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.

Definition

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

Type parameters

NameDescription
O

Parameters

NameTypeDescription
indexnumber
otherwiseOptLazy<O>
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.getKeyAtIndex(1))
// => 'b'
console.log(m.getKeyAtIndex(-1))
// => 'd'
console.log(m.getKeyAtIndex(10))
// => undefined
console.log(m.getKeyAtIndex(10, 'q'))
// => 'q'

Overrides

SortedMap.getKeyAtIndex, SortedMapNode.getKeyAtIndex

getSliceRange

undocumented

Definition

getSliceRange(range: Range<K>): {
    startIndex: number;
    endIndex: number;
  };

Parameters

NameTypeDescription
rangeRange<K>

Overrides

SortedMapNode.getSliceRange

getValueAtIndex

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.

Definition

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

Type parameters

NameDescription
O

Parameters

NameTypeDescription
indexnumber
otherwiseOptLazy<O>
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.getValueAtIndex(1))
// => 2
console.log(m.getValueAtIndex(-1))
// => 4
console.log(m.getValueAtIndex(10))
// => undefined
console.log(m.getValueAtIndex(10, 'q'))
// => 'q'

Overrides

SortedMap.getValueAtIndex, SortedMapNode.getValueAtIndex

hasKey

undocumented

Definition

hasKey<UK>(key: RelatedTo<K, UK>): boolean;

Type parameters

NameDescription
UK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>

Overrides

SortedMapNode.hasKey

mapValues

undocumented

Definition

mapValues<V2>(mapFun: (value: V, key: K) => V2): SortedMapLeaf<K, V2>;

Type parameters

NameDescription
V2

Parameters

NameTypeDescription
mapFun(value: V, key: K) => V2

Overrides

SortedMapNode.mapValues

max

undocumented

Definition

max(): readonly [K, V];

Overrides

SortedMapNode.max

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())
// => 'a'

Overrides

NonEmpty.maxKey, SortedMapNode.maxKey

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

Overrides

NonEmpty.maxValue, SortedMapNode.maxValue

min

undocumented

Definition

min(): readonly [K, V];

Overrides

SortedMapNode.min

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'

Overrides

NonEmpty.minKey, SortedMapNode.minKey

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

Overrides

NonEmpty.minValue, SortedMapNode.minValue

modifyAt

Returns the collection with the given atKey key modified according to given options.

Definition

modifyAt(atKey: K, options: {
    ifNew?: OptLazyOr<V, Token>;
    ifExists?: ((currentEntry: V, remove: Token) => V |Token)| V;
  }): SortedMap<K, V>;

Parameters

NameTypeDescription
atKeyK
options{
    ifNew?: OptLazyOr<V, Token>;
    ifExists?: ((currentEntry: V, remove: Token) => V |Token)| V;
  }
example
const m = HashMap.of([1, 'a'], [2, 'b'])
m.modifyAt(3, { ifNew: 'c' }).toArray()
// => [[1, 'a'], [2, 'b'], [3, 'c']]
m.modifyAt(3, { ifNew: (none) => 1 < 2 ? none : 'c' }).toArray()
// => [[1, 'a'], [2, 'b']]
m.modifyAt(2, { ifExists: () => 'c' }).toArray()
// => [[1, 'a'], [2, 'c']]
m.modifyAt(2, { ifExists: (v) => v + 'z' }).toArray()
// => [[1, 'a'], [2, 'bz']]
m.modifyAt(2, { ifExists: (v, remove) => v === 'a' ? v : remove }).toArray()
// => [[1, 'a']]

Overrides

RMapBase.modifyAt, SortedMapNode.modifyAt

modifyAtInternal

undocumented

Definition

modifyAtInternal(key: K, options: {
    ifNew?: OptLazyOr<V, Token>;
    ifExists?: ((currentEntry: V, remove: Token) => V |Token)| V;
  }): SortedMapNode<K, V>;

Parameters

NameTypeDescription
keyK
options{
    ifNew?: OptLazyOr<V, Token>;
    ifExists?: ((currentEntry: V, remove: Token) => V |Token)| V;
  }

Overrides

SortedMapNode.modifyAtInternal

mutateGetFromLeft

undocumented

Definition

mutateGetFromLeft(left: SortedMapLeaf<K, V>, toMe: readonly [K, V]): [readonly [K, V], SortedMapLeaf<K, V>];

Parameters

NameTypeDescription
leftSortedMapLeaf<K, V>
toMereadonly [K, V]

mutateGetFromRight

undocumented

Definition

mutateGetFromRight(right: SortedMapLeaf<K, V>, toMe: readonly [K, V]): [readonly [K, V], SortedMapLeaf<K, V>];

Parameters

NameTypeDescription
rightSortedMapLeaf<K, V>
toMereadonly [K, V]

mutateGiveToLeft

undocumented

Definition

mutateGiveToLeft(left: SortedMapLeaf<K, V>, toLeft: readonly [K, V]): [readonly [K, V], SortedMapLeaf<K, V>];

Parameters

NameTypeDescription
leftSortedMapLeaf<K, V>
toLeftreadonly [K, V]

mutateGiveToRight

undocumented

Definition

mutateGiveToRight(right: SortedMapLeaf<K, V>, toRight: readonly [K, V]): [readonly [K, V], SortedMapLeaf<K, V>];

Parameters

NameTypeDescription
rightSortedMapLeaf<K, V>
toRightreadonly [K, V]

mutateJoinLeft

undocumented

Definition

mutateJoinLeft(left: SortedMapLeaf<K, V>, entry: readonly [K, V]): void;

Parameters

NameTypeDescription
leftSortedMapLeaf<K, V>
entryreadonly [K, V]

mutateJoinRight

undocumented

Definition

mutateJoinRight(right: SortedMapLeaf<K, V>, entry: readonly [K, V]): void;

Parameters

NameTypeDescription
rightSortedMapLeaf<K, V>
entryreadonly [K, V]

mutateSplitRight

undocumented

Definition

mutateSplitRight(index?: number): [readonly [K, V], SortedMapLeaf<K, V>];

Parameters

NameTypeDescription
indexnumber

nonEmpty

Returns true since this collection is known to be non-empty

Definition

nonEmpty(): true;

example
HashMap.of([1, 1], [2, 2]).nonEmpty()   // => true

Overrides

VariantMapBase.nonEmpty, NonEmpty.nonEmpty

normalize

undocumented

Definition

normalize(): SortedMap<K, V>;

Overrides

SortedMapNode.normalize

removeKey

undocumented

Definition

removeKey<UK>(key: RelatedTo<K, UK>): SortedMap<K, V>;

Type parameters

NameDescription
UK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>

Overrides

SortedMapNode.removeKey

removeKeyAndGet

undocumented

Definition

removeKeyAndGet<UK>(key: RelatedTo<K, UK>): [SortedMap<K, V>, V] | undefined;

Type parameters

NameDescription
UK

Parameters

NameTypeDescription
keyRelatedTo<K, UK>

Overrides

SortedMapNode.removeKeyAndGet

removeKeys

undocumented

Definition

removeKeys<UK>(keys: StreamSource<RelatedTo<K, UK>>): SortedMap<K, V>;

Type parameters

NameDescription
UK

Parameters

NameTypeDescription
keysStreamSource<RelatedTo<K, UK>>

Overrides

SortedMapNode.removeKeys

set

Returns the collection with the given key associated to the given value.

Definition

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

Parameters

NameTypeDescription
keyK
valueV
example
HashMap.of([1, 'a']).set(2, 'b').toArray()   // => [[1, 'a'], [2, 'b']]
HashMap.of([1, 'a']).set(1, 'b').toArray() // => [[1, 'b']]
note

if the key is already associated, the previous value will be 'replaced'

Overrides

RMapBase.set, SortedMapNode.set

slice

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

Definition

slice(range: Range<K>): SortedMap<K, V>;

Parameters

NameTypeDescription
rangeRange<K>
example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]).asNormal();
console.log(m.slice({ start: 'b', end: 'c' }).toArray())
// => [['b', 2], ['c', 3]]

Overrides

SortedMap.slice, SortedMapNode.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
rangeIndexRange
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, SortedMapNode.sliceIndex

stream

undocumented

Definition

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

Parameters

NameTypeDescription
options{
    reversed?: boolean;
  }

Overrides

SortedMapNode.stream

streamKeys

undocumented

Definition

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

Parameters

NameTypeDescription
options{
    reversed?: boolean;
  }

Overrides

NonEmpty.streamKeys, SortedMapNode.streamKeys

streamRange

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

Definition

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

Parameters

NameTypeDescription
keyRangeRange<K>
options{
    reversed?: boolean;
  }
example
const m = SortedMap.of(['b', 2], ['d', 4], ['a', 1], ['c', 3]);
console.log(m.streamRange({ start: 'b', end: 'c' }).toArray())
// => ['b', 'c']

Overrides

SortedMap.streamRange, SortedMapNode.streamRange

streamSliceIndex

undocumented

Definition

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

Parameters

NameTypeDescription
rangeIndexRange
options{
    reversed?: boolean;
  }

Overrides

SortedMapNode.streamSliceIndex

streamValues

undocumented

Definition

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

Parameters

NameTypeDescription
options{
    reversed?: boolean;
  }

Overrides

NonEmpty.streamValues, SortedMapNode.streamValues

take

undocumented

Definition

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

Parameters

NameTypeDescription
amountnumber

Overrides

NonEmpty.take, SortedMapNode.take

takeInternal

undocumented

Definition

takeInternal(amount: number): SortedMapLeaf<K, V>;

Parameters

NameTypeDescription
amountnumber

toArray

undocumented

Definition

toArray(): ArrayNonEmpty<[K, V]>;

Overrides

SortedMapNode.toArray

toBuilder

Returns a builder object containing the entries of this collection.

Definition

toBuilder(): SortedMapBuilder<K, V>;

example
const builder: HashMap.Builder<number, string> = HashMap.of([1, 'a'], [2, 'b']).toBuilder()

Overrides

RMapBase.toBuilder, SortedMapNode.toBuilder

toJSON

undocumented

Definition

toJSON(): ToJSON<(readonly [K, V])[]>;

Overrides

SortedMapNode.toJSON

toString

undocumented

Definition

toString(): string;

Overrides

SortedMapNode.toString

updateAt

Returns the collection where the value associated with given key is updated with the given update value or update function.

Definition

updateAt<U>(key: RelatedTo<K, U>, update: Update<V>): SortedMap.NonEmpty<K, V>;

Type parameters

NameDescription
U

Parameters

NameTypeDescription
keyRelatedTo<K, U>
updateUpdate<V>
example
const m = HashMap.of([1, 'a'], [2, 'b'])
m.updateAt(3, 'a').toArray()
// => [[1, 'a'], [2, 'b']]
m.updateAt(2, 'c').toArray()
// => [[1, 'a'], [2, 'c']]
m.updateAt(2, v => v + 'z')
// => [[1, 'a'], [2, 'cz]]

Overrides

NonEmpty.updateAt, SortedMapNode.updateAt