Expand description
A Map containing arrays of items
This class contains the standard Map
methods as well as a subset of
Array
methods for convenient access to the underlying array.
import { ArrayMap } from '@woubuc/multimap';
let map = new ArrayMap();
map.set('foo', [1]); // foo: [1]
map.push('foo', 2); // foo: [1, 2]
map.delete('foo'); // foo: undefined
map.push('foo', 3); // foo: [3]
Constructors
constructor
constructor
new <TKey, TValue>(): ArrayMap<TKey, TValue>
new <TKey, TValue>(): ArrayMap<TKey, TValue>
Accessors
Methods
sourceflatForEach
flatForEach
sourcesort
sort
source(key: TKey, compareFn?: ((a: TValue, b: TValue) => number)): void
(key: TKey, compareFn?: ((a: TValue, b: TValue) => number)): void
Sorts the elements of the array at key
in place, with an optional
compare function.
Uses the standard Array.sort()
functionality so the same complexity
and considerations apply.
If no entry exists for key
, creates a new array.