Skip to main content

MultiMap

A Rimbu MultiMap is a Map in which each key has one or more values. For each key, it's associated values are unique, that is, the values for each key are kept in a Set.

When to use#

A MultiMap is useful when there is a one to many relation between two types of entities. For example, one planet can have many moons, so if we have a MultiMap from Planet to Moon, we can easily find all the moons that belong to a particular planet. However, if we also easily want to know to which planet a moon belongs, it would be better to use a BiMultiMap

tip

The predefined immutable MultiMap implementations do not maintain the insertion order of the values per key. However, it is possible to create a custom context with an OrderedMap implementation to achieve this behavior.

Exports#

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

NameDescription
VariantMultiMap<K, V>a type-variant multimap between values of type K and values of type V
MultiMap<K, V>a generic multimap between values of type K and values of type V

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

NameDescription
HashMultiMapHashValue<K, V>a multimap between hashed values of type K and hashed values of type V
HashMultiMapSortedValue<K, V>a multimap between hashed values of type K and sorted values of type V
SortedMultiMapHashValue<K, V>a multimap between sorted values of type K and hashed values of type V
SortedMultiMapSortedValue<K, V>a multimap between sorted values of type K and sorted values of type V

Inheritance#

Usage#

Creation#

Open file below in new window with full type-check

Query#

Open file below in new window with full type-check

Builder#

Open file below in new window with full type-check