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

new <TKey, TValue>(): ArrayMap<TKey, TValue>

Accessors

override

The number of entries in the map

Methods

Removes all entries from the map

Removes the collection at key from the map.

Iterates over the key/value pairs of the map.

override

Executes a callback for all items in all collections in the map.

This method flattens the entries, so the iterator may contain the same key multiple times. It will also skip over empty collections.

override

Executes a callback for each entry in the map

override

Checks if key exists in the map.

Iterates over the keys of the map

Removes the last element from the array at key.

If no entry exists for key, creates a new array.

Adds one or more items to the end of the array at key.

If no entry exists for key, creates a new array.

Reverses the array at key in place.

If no entry exists for key, creates a new array.

Sets the collection at key.

If no entry exists for key, returns an empty collection.

Removes the first element from the array at key and returns the removed element.

If no entry exists for key, creates a new array.

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.

Adds one or more items to the beginning of the array at key.

If no entry exists for key, creates a new array.

Iterates over the values of the map