Skip to main content

BiMultiMap

A BiMultiMap is a bidirectional MultiMap of keys and values, where each key-value association also has an inverse value-key association. There is a many-to-many mapping between keys and values.

When to use#

The BiMultiMap is useful when there is a many-to-many relation between to types of entities, and it is desired to query the relation in both directions.

For example, take a relation between persons and their hobbies. The BiMultiMap can efficiently tell you, given a person, what her hobbies are. But it can also efficiently tell you, given a hobby, which persons practice it.

info

Internally the BiMultiMap uses two immutable MultiMaps, making lookup operations in both directions fast. Insertion and memory usage are double that of a MultiMap.

Exports#

The @rimbu/core package exports the following abstract BiMultiMap TypeScript types:

NameDescription
BiMultiMap<K, V>a generic BiMultiMap between keys of type K and values of type V

The @rimbu/core package exports the following concrete BiMultiMap types:

NameDescription
HashBiMultiMap<K, V>a BiMultiMap implementation where keys and values are hashed
SortedBiMultiMap<K, V>a BiMultiMap implementation where keys and values are sorted

Inheritance#

Creation#

Open file below in new window with full type-check

Query#

Open file below in new window with full type-check

Motivation#

Open file below in new window with full type-check

Builder#

Open file below in new window with full type-check