Skip to main content

namespace SortedMultiMapHashValue

A type-invariant immutable MultiMap of key type K, and value type V. In the MultiMap, each key has at least one value. See the MultiMap documentation and the SortedMultiMapHashValue API documentation

Companion interface: SortedMultiMapHashValue<K,V>

Interfaces​

NameDescription
SortedMultiMapHashValue.Builder<K,V>A mutable SortedMultiMapHashValue builder used to efficiently create new immutable instances. See the MultiMap documentation and the SortedMultiMapHashValue.Builder API documentation
SortedMultiMapHashValue.Context<UK,UV>A context instance for an SortedMultiMapHashValue that acts as a factory for every instance of this type of collection.
SortedMultiMapHashValue.NonEmpty<K,V>A non-empty type-invariant immutable MultiMap of key type K, and value type V. In the MultiMap, each key has at least one value. See the MultiMap documentation and the SortedMultiMapHashValue API documentation
SortedMultiMapHashValue.TypesUtility interface that provides higher-kinded types for this collection.

Static Methods​

builder​

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

Definition​

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

Type parameters​

NameConstraintsDescription
KUK
VUV
example
HashMultiMapHashValue.builder<number, string>()    // => HashMultiMapHashValue.Builder<number, string>

Overrides​

Factory.builder

createContext​

Returns a new SortedMultiMapHashValue context instance based on the given options.

Definition​

createContext<K, V>(options?: {
    keyMapContext?: SortedMap.Context<K>;
    keyMapValuesContext?: HashSet.Context<V>;
  }): SortedMultiMapHashValue.Context<K, V>;

Type parameters​

NameDescription
Kthe upper key type for which the context can create instances
Vthe upper value type for which the context can create instances

Parameters​

NameTypeDescription
options{
    keyMapContext?: SortedMap.Context<K>;
    keyMapValuesContext?: HashSet.Context<V>;
  }
(optional) an object containing the following properties:
- keyMapContext: (optional) the map context to use for key to valueset mappings
- keyMapValuesContext: (optional) the set context to use for value sets

defaultContext​

Returns the default context for SortedMultiMapHashValue.

Definition​

defaultContext<K, V>(): SortedMultiMapHashValue.Context<K, V>;

Type parameters​

NameDescription
Kthe upper key type for which the context can create instances
Vthe upper value type for which the context can create instances

empty​

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

Definition​

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

Type parameters​

NameConstraintsDescription
KUK
VUV
example
HashMultiMapHashValue.empty<number, string>()    // => HashMultiMapHashValue<number, string>
HashMultiMapHashValue.empty<string, boolean>() // => HashMultiMapHashValue<string, boolean>

Overrides​

Factory.empty

from​

Returns an immutable multimap of this type and context, containing the entries in the given source StreamSource.

Definitions​

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

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

Type parameters​

NameConstraintsDescription
KUK
VUV

Parameters​

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

Overrides​

Factory.from

of​

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

Definition​

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

Type parameters​

NameConstraintsDescription
KUK
VUV

Parameters​

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

Overrides​

Factory.of

reducer​

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

Definition​

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

Type parameters​

NameConstraintsDescription
KUK
VUV

Parameters​

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

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

Overrides​

Factory.reducer