A BiMap is a bidirectional Map of keys and values, where each key has exactly one value, and each value has exactly one key. There is a one-to-one mapping between keys and values.
This package exports the following types:
Name | Description |
---|---|
BiMap<K, V> |
a generic BiMap between keys of type K and values of type V |
HashBiMap<K, V> |
a BiMap between keys of type K and values of type V, where both the keys and values are hashed |
SortedBiMap<K, V> |
a BiMap between keys of type K and values of type V, where both the keys and values are sorted |
For complete documentation please visit the Rimbu Docs.
Or Try Me Out in CodeSandBox.
All types are exported through @rimbu/core
. It is recommended to use this package.
To install separately:
yarn add @rimbu/bimap
or
npm i @rimbu/bimap
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
}
}
import { HashBiMap } from '@rimbu/bimap';
const biMap = HashBiMap.of([1, 'a'], [2, 'b'], [3, 'b']);
console.log(biMap.toString());
// HashBiMap(3 -> b)
Feel very welcome to contribute to further improve Rimbu. Please read our Contributing guide.
Made with contributors-img.
Licensed under the MIT License, Copyright © 2020-present Arvid Nicolaas.
See LICENSE for more information.