Skip to main content

class HashMapContext<UK>

undocumented

Extends: ContextBase<UK,Tp>

Implements: HashMap.Context<UK>

Type parameters

NameDescription
UKundocumented

Properties

_empty

undocumented

Definition

readonly _empty: HashMap<any, any>;

Overrides

ContextBase._empty

_emptyBlock

undocumented

Definition

readonly _emptyBlock: HashMapBlock<any, any>;

_fixedKeyType

undocumented

Definition

_fixedKeyType: any;

Overrides

Context._fixedKeyTypeContextBase._fixedKeyType

_types

undocumented

Definition

get _types(): Tp;

Overrides

Context._typesContextBase._types

blockCapacity

undocumented

Definition

readonly blockCapacity: number;

blockMask

undocumented

Definition

readonly blockMask: number;

blockSizeBits

undocumented

Definition

readonly blockSizeBits: number;

builder

undocumented

Definition

readonly builder: <K extends UK, V>() => HashMap.Builder<K, V>;

Overrides

ContextBase.builder

empty

undocumented

Definition

readonly empty: <K extends UK, V>() => WithKeyValue<Tp, K, V>["normal"];

Overrides

ContextBase.empty

eq

undocumented

Definition

readonly eq: Eq<UK>;

Overrides

Context.eq

from

undocumented

Definition

readonly from: any;

Overrides

ContextBase.from

hasher

undocumented

Definition

readonly hasher: Hasher<UK>;

Overrides

Context.hasher

listContext

undocumented

Definition

readonly listContext: List.Context;

maxDepth

undocumented

Definition

readonly maxDepth: number;

merge

undocumented

Definition

readonly merge: any;

Overrides

ContextBase.merge

mergeAll

undocumented

Definition

readonly mergeAll: any;

Overrides

ContextBase.mergeAll

mergeAllWith

undocumented

Definition

readonly mergeAllWith: any;

Overrides

ContextBase.mergeAllWith

mergeWith

undocumented

Definition

readonly mergeWith: any;

Overrides

ContextBase.mergeWith

of

undocumented

Definition

readonly of: <K extends UK, V>(values_0: readonly [K, V], ...values_1: (readonly [K, V])[]) => K extends UK ? WithKeyValue<Tp, K, V>["nonEmpty"] : never;

Overrides

ContextBase.of

reducer

undocumented

Definition

readonly reducer: <K extends UK, V>(source?: StreamSource<readonly [K, V]>) => Reducer<readonly [K, V], WithKeyValue<Tp, K, V>["normal"]>;

Overrides

ContextBase.reducer

typeTag

undocumented

Definition

readonly typeTag = "HashMap";

Overrides

ContextBase.typeTagContext.typeTag

Methods

block

undocumented

Definition

block<V>(entries: (readonly [UK, V])[] |null, entrySets:MapEntrySet<UK, V>[] |null, size: number, level: number):HashMapBlock<UK, V>;

Type parameters

NameDescription
V

Parameters

NameTypeDescription
entries(readonly [UK, V])[] | null
entrySetsMapEntrySet<UK, V>[] | null
sizenumber
levelnumber

builder

Returns an empty builder instance for this type of collection and context.

Definition

builder<K extends UK, V>(): WithKeyValue<Tp, K, V>['builder'];

Type parameters

NameConstraintsDescription
KUK
V
example
HashMap.builder<number, string>()    // => HashMap.Builder<number, string>

Overrides

Factory.builder

collision

undocumented

Definition

collision<V>(entries: List.NonEmpty<readonly [UK, V]>): HashMapCollision<UK, V>;

Type parameters

NameDescription
V

Parameters

NameTypeDescription
entriesList.NonEmpty<readonly [UK, V]>

createBuilder

undocumented

Definition

createBuilder<K extends UK, V>(source?: HashMap.NonEmpty<K, V>): HashMap.Builder<K, V>;

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourceHashMap.NonEmpty<K, V>

empty

Returns the (singleton) empty instance of this type and context with given key and value types.

Definition

empty<K extends UK, V>(): WithKeyValue<Tp, K, V>['normal'];

Type parameters

NameConstraintsDescription
KUK
V
example
HashMap.empty<number, string>()    // => HashMap<number, string>
HashMap.empty<string, boolean>() // => HashMap<string, boolean>

Overrides

Factory.empty

emptyBlock

undocumented

Definition

emptyBlock<V>(): HashMapBlock<UK, V>;

Type parameters

NameDescription
V

from

Returns an immutable map of this type and context, containing the entries in the given sources StreamSource instances.

Definitions

from<K extends UK, V>(...sources: ArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>): WithKeyValue<Tp, K, V>['nonEmpty'];

from<K, V>(...sources: ArrayNonEmpty<StreamSource<readonly [K, V]>>): WithKeyValue<Tp, K, V>['normal'];

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourcesArrayNonEmpty<StreamSource.NonEmpty<readonly [K, V]>>an array of StreamSource instances containing key-value entries
example
HashMap.from([[1, 'a'], [2, 'b']])    // => HashMap.NonEmpty<number, string>

Overrides

Factory.from

getKeyIndex

undocumented

Definition

getKeyIndex(level: number, hash: number): number;

Parameters

NameTypeDescription
levelnumber
hashnumber

hash

undocumented

Definition

hash(value: UK): number;

Parameters

NameTypeDescription
valueUK

isHashMapBlock

undocumented

Definition

isHashMapBlock<K, V>(obj: MapEntrySet<K, V>): obj is HashMapBlock<K, V>;

Type parameters

NameDescription
K
V

Parameters

NameTypeDescription
objMapEntrySet<K, V>

isHashMapBlockBuilder

undocumented

Definition

isHashMapBlockBuilder<K, V>(obj: MapBlockBuilderEntry<K, V>): obj is HashMapBlockBuilder<K, V>;

Type parameters

NameDescription
K
V

Parameters

NameTypeDescription
objMapBlockBuilderEntry<K, V>

isNonEmptyInstance

undocumented

Definition

isNonEmptyInstance(source: any): source is any;

Parameters

NameTypeDescription
sourceany

Overrides

ContextBase.isNonEmptyInstance

isValidKey

undocumented

Definition

isValidKey(key: unknown): key is UK;

Parameters

NameTypeDescription
keyunknown

Overrides

ContextBase.isValidKey, Context.isValidKey

merge

Returns a Map containing the common keys from this map and all the given sources key-value stream sources, and as values tuples of all the corresponding values for each common key. If a source doesn't have a key, the key will be skipped.

Definitions

merge<K extends UK, I extends readonly [unknown, unknown, ...unknown[]]>(...sources: {
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]): WithKeyValue<Tp, K, {
      [KT in keyof I]: I[KT];
    }>['nonEmpty'];

merge<K extends UK, I extends readonly [unknown, unknown, ...unknown[]]>(...sources: {
      [KT in keyof I]: StreamSource<readonly [K, I[KT]]>;
    } & unknown[]): WithKeyValue<Tp, K, {
      [KT in keyof I]: I[KT];
    }>['normal'];

Type parameters

NameConstraintsDescription
KUKthe common key type
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.merge(m, [[2, true]], HashMap.of([2, 15]))
// type of m2: HashMap<number, [string, boolean, number]>
console.log(m2.toArray())
// => [[2, ['b', true, 15]]]

Overrides

Factory.merge

mergeAll

Returns a Map containing all keys from this map and all the given sources key-value stream sources, and as values tuples of all the corresponding values for each key. If a source doesn't have a key, the tuple will be filled with the given fillValue.

Definitions

mergeAll<O, I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(fillValue: O, ...sources: {
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]): WithKeyValue<Tp, K, {
      [KT in keyof I]: I[KT] | O;
    }>['nonEmpty'];

mergeAll<O, I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(fillValue: O, ...sources: {
      [KT in keyof I]: StreamSource<readonly [K, I[KT]]>;
    } & unknown[]): WithKeyValue<Tp, K, {
      [KT in keyof I]: I[KT] | O;
    }>['normal'];

Type parameters

NameConstraintsDescription
Othe type of the fill value
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
fillValueOthe value to use for the result tuple if a source does not have a certain key
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeAll('none', m, [[2, true]], HashMap.of([3, 15]))
// type of m2: HashMap<number, [string, boolean | string, number | string]>
console.log(m2.toArray())
// => [[1, ['a', 'none', 'none']], [2, ['b', true, 'none']], [3, ['none', 'none', 15]]]

Overrides

Factory.mergeAll

mergeAllWith

Returns a Map containing all keys from this map and all the given sources key-value stream sources, and as values the result of applying the given mergeFun to the key and all the corresponding values for each key. If a source doesn't have a key, the given tuple will be filled with the given fillValue.

Definitions

mergeAllWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: {
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]): <O, R>(fillValue: O, mergeFun: (key: K, ...values: {
      [KT in keyof I]: I[KT] | O;
    }) => R) => WithKeyValue<Tp, K, R>['nonEmpty'];

mergeAllWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: {
      [KT in keyof I]: StreamSource<readonly [K, I[KT]]>;
    } & unknown[]): <O, R>(fillValue: O, mergeFun: (key: K, ...values: {
      [KT in keyof I]: I[KT] | O;
    }) => R) => WithKeyValue<Tp, K, R>['normal'];

Type parameters

NameConstraintsDescription
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeAllWith(
m
[[2, 'c']],
HashMap.of([3, 'd'])
)(
'q',
(key, v1, v2, v3) => `${key}${v1}${v2}${v3}`
)
// type of m2: HashMap<number, string>
console.log(m2.toArray())
// => [[1, '1aqq'], [2, '2bcq'], [3, '3qqd']]

Overrides

Factory.mergeAllWith

mergeWith

Returns a Map containing the common keys from this map and all the given sources key-value stream sources, and as values the result of applying given mergeFun to the key and values of all the corresponding values for each common key. If a source doesn't have a key, the key will be skipped.

Definitions

mergeWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: {
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]): <R>(mergeFun: (key: K, ...values: I) => R) => WithKeyValue<Tp, K, R>['nonEmpty'];

mergeWith<I extends readonly [unknown, unknown, ...unknown[]], K extends UK>(...sources: {
      [KT in keyof I]: StreamSource<readonly [K, I[KT]]>;
    } & unknown[]): <R>(mergeFun: (key: K, ...values: I) => R) => WithKeyValue<Tp, K, R>['normal'];

Type parameters

NameConstraintsDescription
Ireadonly [unknown, unknown, ...unknown[]]the array of input source value types
KUKthe common key type

Parameters

NameTypeDescription
sources{
      [KT in keyof I]: StreamSource.NonEmpty<readonly [K, I[KT]]>;
    } & unknown[]
a non-empty set of StreamSouces containing tuples of keys and values
example
const m = HashMap.of([1, 'a'], [2, 'b'])
const m2 = HashMap.mergeWith(
m,
[[2, true]],
HashMap.of([2, 15])
)(
(key, v1, v2) => `${key}${v1}${v2}`,
)
// type of m2: HashMap<number, string>
console.log(m2.toArray())
// => [[2, '2true15']]

Overrides

Factory.mergeWith

of

Returns an immutable map of this collection type and context, containing the given entries.

Definition

of<K extends UK, V>(...entries: ArrayNonEmpty<readonly [K, V]>): WithKeyValue<Tp, K, V>['nonEmpty'];

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
entriesArrayNonEmpty<readonly [K, V]>a non-empty array of key-value entries
example
HashMap.of([1, 'a'], [2, 'b'])    // => HashMap.NonEmpty<number, string>

Overrides

Factory.of

reducer

Returns a Reducer that adds received tuples to an RMap and returns the RMap as a result. When a source is given, the reducer will first create an RMap from the source, and then add tuples to it.

Definition

reducer<K extends UK, V>(source?: StreamSource<readonly [K, V]>): Reducer<readonly [K, V], WithKeyValue<Tp, K, V>['normal']>;

Type parameters

NameConstraintsDescription
KUK
V

Parameters

NameTypeDescription
sourceStreamSource<readonly [K, V]>(optional) an initial source of tuples to add to
example
const someSource = HashMap.of([1, 'a'], [2, 'b']);
const result = Stream.of([1, 'c'], [3, 'a']).reduce(HashMap.reducer(someSource))
result.toArray() // => [[1, 'c'], [2, 'b'], [3, 'a']]
note

uses a builder under the hood. If the given source is an RMap in the same context, it will directly call .toBuilder().

Overrides

Factory.reducer