Skip to main content
Module

x/rimbu/bimultimap/README.md

Rimbu is a TypeScript library focused on immutable, performant, and type-safe collections and other tools.
Go to Latest
File

@rimbu/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.

This package exports the following types:

Name Description
BiMultiMap<K, V> a generic BiMultiMap between keys of type K and values of type V
HashBiMultiMap<K, V> a BiMultiMap implementation where keys and values are hashed
SortedBiMultiMap<K, V> a BiMultiMap implementation where keys and values are sorted

For complete documentation please visit the Rimbu Docs.

Or Try Me Out in CodeSandBox.

Installation

All types are exported through @rimbu/core. It is recommended to use this package.

To install separately:

yarn add @rimbu/bimultimap

or

npm i @rimbu/bimultimap

Rimbu uses advanced and recursive typing, potentially making the TypeScript compiler quite slow in some cases, or causing infinite recursion. It is recommended to set the following values in the tsconfig.json file of your project:

{
  "compilerOptions": {
    "skipLibCheck": true,
    "noStrictGenericChecks": true
  }
}

Usage

import { HashBiMultiMap } from '@rimbu/bimultimap';

const biMultiMap = HashBiMultiMap.of([1, 'a'], [2, 'b'], [3, 'b']);
console.log(biMultiMap.toString());
// HashBiMultiMap(1 <-> ['a'], 2 <-> ['b'], 3 <-> ['b'])

console.log(biMultiMap.getValues(1).toArray());
// ['a']
console.log(biMultiMap.getKeys('b').toArray());
// [2, 3]

Author

Arvid Nicolaas

Contributing

Feel very welcome to contribute to further improve Rimbu. Please read our Contributing guide.

Contributors

Made with contributors-img.

License

Licensed under the MIT License, Copyright © 2020-present Arvid Nicolaas.

See LICENSE for more information.