README
@rimbu/bimap
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 BiMap page in the Rimbu Docs.
Or Try Out Rimbu in CodeSandBox.
Installation
All types are exported through @rimbu/core
. It is recommended to use that package.
To install this package only:
Yarn/NPM
yarn add @rimbu/bimap
or
npm i @rimbu/bimap
Deno
Create a file called rimbu.ts
and add the following:
export * from 'https://deno.land/x/rimbu/bimap/mod.ts';
Or using a pinned version (x.y.z
):
export * from 'https://deno.land/x/rimbu/bimap@x.y.z/mod.ts';
Then import what you need from rimbu.ts
:
import { HashBiMultiMap } from './rimbu.ts';
Because Rimbu uses complex types, it's recommended to use the --no-check
flag (your editor should already have checked your code) and to specify a tsconfig.json
file with the settings described below.
Running your script then becomes:
deno run --no-check --config tsconfig.json <your-script>.ts
Usage
import { HashBiMap } from '@rimbu/bimap';
const biMap = HashBiMap.of([1, 'a'], [2, 'b'], [3, 'b']);
console.log(biMap.toString());
// HashBiMap(3 -> b)
Author
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.