namespace SortedBiMultiMap
A type-invariant immutable bi-directional MultiMap where keys and values have a many-to-many mapping. Its keys and values are sorted. See the BiMultiMap documentation and the HashBiMultiMap API documentation
Companion interface: SortedBiMultiMap<K,V>
Interfaces
Name | Description |
---|---|
SortedBiMultiMap.Builder<K,V> | A mutable SortedBiMultiMap builder used to efficiently create new immutable instances. See the BiMultiMap documentation and the HashBiMultiMap.Builder API documentation |
SortedBiMultiMap.Context<UK,UV> | The SortedBiMultiMap's Context instance that serves as a factory for all related immutable instances and builders. |
SortedBiMultiMap.NonEmpty<K,V> | A non-empty type-invariant immutable bi-directional MultiMap where keys and values have a many-to-many mapping. Its keys and values are sorted. See the BiMultiMap documentation and the HashBiMultiMap API documentation |
SortedBiMultiMap.Types | Utility interface that provides higher-kinded types for this collection. |
Static Methods
builder
Returns an empty BiMultiMap
builder instance.
builder
BiMultiMap
builder instance.Definition
builder<K extends UK, V extends UV>():
WithKeyValue
<Tp, K, V>['builder'];
Type parameters
Name | Constraints | Description |
---|---|---|
K | UK | |
V | UV |
HashBiMultiMap.builder<number, string>() // => HashBiMultiMap.Builder<number, string>
Overrides
createContext
Returns a new SortedBiMultiMap context instance based on the given options
.
createContext
options
.Definition
createContext<K, V>(options?: {
keyValueMultiMapContext?:
SortedMultiMapSortedValue.Context
<K, V>;
valueKeyMultiMapContext?:
SortedMultiMapSortedValue.Context
<V, K>;
}):
SortedBiMultiMap.Context
<K, V>;
Type parameters
Name | Description |
---|---|
K | |
V |
Parameters
Name | Type | Description |
---|---|---|
options | { keyValueMultiMapContext?: SortedMultiMapSortedValue.Context <K, V>; valueKeyMultiMapContext?: SortedMultiMapSortedValue.Context <V, K>; } | (optional) an object containing the following properties: - keyValueMultiMapContext: (optional) the map context to use for key value multimaps - valueKeyMultiMapContext: (optional) the set context to use for value key multimaps |
defaultContext
Returns the default context for SortedBiMultiMap.
defaultContext
Definition
defaultContext<UK, UV>():
SortedBiMultiMap.Context
<UK, UV>;
Type parameters
Name | Description |
---|---|
UK | the upper key type for which the context can create instances |
UV | the 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.
empty
Definition
empty<K extends UK, V extends UV>():
WithKeyValue
<Tp, K, V>['normal'];
Type parameters
Name | Constraints | Description |
---|---|---|
K | UK | |
V | UV |
HashBiMultiMap.empty<number, string>() // => HashBiMultiMap<number, string>
HashBiMultiMap.empty<string, boolean>() // => HashBiMultiMap<string, boolean>
Overrides
from
Returns an immutable BiMultiMap, containing the entries in the given sources
StreamSource
instances.
from
sources
StreamSource
instances.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
Name | Constraints | Description |
---|---|---|
K | UK | |
V | UV |
Parameters
Name | Type | Description |
---|---|---|
sources | ArrayNonEmpty < StreamSource.NonEmpty <readonly [K, V]>> | an array of StreamSource instances contaning key-value entries |
HashBiMultiMap.from([[1, 'a'], [2, 'b']]) // => HashBiMultiMap.NonEmpty<number, string>
Overrides
of
Returns an immutable BiMultiMap, containing the given entries
.
of
entries
.Definition
of<K extends UK, V extends UV>(...entries:
ArrayNonEmpty
<readonly [K, V]>):
WithKeyValue
<Tp, K, V>['nonEmpty'];
Type parameters
Name | Constraints | Description |
---|---|---|
K | UK | |
V | UV |
Parameters
Name | Type | Description |
---|---|---|
entries | ArrayNonEmpty <readonly [K, V]> | a non-empty array of key-value entries |
HashBiMultiMap.of([1, 'a'], [2, 'b']) // => HashBiMultiMap.NonEmpty<number, string>
Overrides
reducer
Returns a Reducer
that adds received tuples to a BiMultiMap and returns the BiMultiMap as a result. When a source
is given, the reducer will first create a BiMultiMap from the source, and then add tuples to it.
reducer
Reducer
that adds received tuples to a BiMultiMap and returns the BiMultiMap as a result. When a source
is given, the reducer will first create a BiMultiMap 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
Name | Constraints | Description |
---|---|---|
K | UK | |
V | UV |
Parameters
Name | Type | Description |
---|---|---|
source | StreamSource <readonly [K, V]> | (optional) an initial source of tuples to add to |
const someSource = BiMultiMap.of([1, 'a'], [2, 'b']);
const result = Stream.of([1, 'c'], [3, 'a']).reduce(BiMultiMap.reducer(someSource))
result.toArray() // => [[1, 'a'], [1, 'c'], [2, 'b'], [3, 'a']]
uses a builder under the hood. If the given source
is a BiMultiMap in the same context, it will directly call .toBuilder()
.