Expand description

A Map containing sets of items

This class contains the standard Map methods as well as a subset of Set methods for convenient access to the underlying set.

import { SetMap } from '@woubuc/multimap';

let map = new SetMap();
map.add('foo', 1); // foo: Set(1)
map.add('foo', 2); // foo: Set(1, 2)
map.add('foo', 1); // foo: Set(1)

Constructors

constructor

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

Accessors

override

The number of entries in the map

Methods

Adds an item to the set at key.

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

Removes all entries from the map

Removes the collection at key from the map.

Removes a specified item from the set, if it is in the set.

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

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

Sets the collection at key.

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

Iterates over the values of the map