Welcome to @rimbu/bimultimap
! A BiMultiMap is a powerful bidirectional MultiMap that allows many-to-many mappings between keys and values. Each key-value association also has an inverse value-key association, making it easy to navigate in both directions.
- Bidirectional MultiMap: Navigate seamlessly between keys and values and vice versa.
- Many-to-Many Mapping: Supports multiple values for a single key and multiple keys for a single value.
- Flexible Implementations: Choose between hashed and sorted implementations based on your needs.
Name | Description |
---|---|
BiMultiMap<K, V> |
A generic BiMultiMap for keys of type K and values of type V . |
HashBiMultiMap<K, V> |
A BiMultiMap where both keys and values are hashed for efficient lookups. |
SortedBiMultiMap<K, V> |
A BiMultiMap where both keys and values are sorted, providing ordered traversal and lookups. |
For complete documentation, please visit the BiMultiMap page in the Rimbu Docs, or directly explore the Rimbu BiMultiMap API Docs.
Experience @rimbu/bimultimap
in action! Try Out Rimbu on CodeSandBox.
Yarn:
yarn add @rimbu/bimultimap
npm:
npm install @rimbu/bimultimap
Bun:
bun add @rimbu/bimultimap
Create or edit import_map.json
in your project root:
{
"imports": {
"@rimbu/": "https://deno.land/x/rimbu@x.y.z/"
}
}
Replace x.y.z
with the desired version.
In this way you can use relative imports from Rimbu in your code, like so:
import { List } from '@rimbu/core/mod.ts';
import { HashMap } from '@rimbu/hashed/mod.ts';
Note that for sub-packages, due to conversion limitations it is needed to import the index.ts
instead of mod.ts
, like so:
import { HashMap } from '@rimbu/hashed/map/index.ts';
To run your script (let's assume the entry point is in src/main.ts
):
deno run --import-map import_map.json src/main.ts
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]
Created and maintained by Arvid Nicolaas.
We welcome contributions! Please read our Contributing guide.
Made with contributors-img.
This project is licensed under the MIT License. See the LICENSE for details.