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.
Internally the BiMultiMap uses two immutable MultiMaps, making lookup operations in both directions fast. Insertion and memory usage are double that of a MultiMap.
@rimbu/core package exports the following abstract BiMultiMap TypeScript types:
|a generic BiMultiMap between keys of type K and values of type V|
@rimbu/core package exports the following concrete BiMultiMap types:
|a BiMultiMap implementation where keys and values are hashed|
|a BiMultiMap implementation where keys and values are sorted|