Skip to content

Latest commit

 

History

History

multimap

npm version Deno

Licence

@rimbu/multimap

Welcome to @rimbu/multimap! A Rimbu MultiMap is a powerful data structure where each key can have one or more unique values, stored in a Set. This ensures that each key's associated values are unique and easily manageable.

Key Features:

  • Multiple Values per Key: Each key can map to multiple unique values.
  • Unique Values: Values for each key are stored in a Set, ensuring uniqueness.
  • Flexible Implementations: Choose between hashed and sorted implementations based on your needs.

Exported Types:

Name Description
HashMultiMapHashValue<K, V> A multimap with hashed keys and hashed values.
HashMultiMapSortedValue<K, V> A multimap with hashed keys and sorted values.
MultiMap<K, V> A generic multimap for keys of type K and values of type V.
SortedMultiMapHashValue<K, V> A multimap with sorted keys and hashed values.
SortedMultiMapSortedValue<K, V> A multimap with sorted keys and sorted values.
VariantMultiMap<K, V> A type-variant multimap for keys of type K and values of type V.

Documentation

For complete documentation, please visit the MultiMap page in the Rimbu Docs, or directly explore the Rimbu MultiMap API Docs.

Try It Out

Experience @rimbu/multimap in action! Try Out Rimbu on CodeSandBox.

Installation

Compabitity

Package Managers

Yarn:

yarn add @rimbu/multimap

npm:

npm install @rimbu/multimap

Bun:

bun add @rimbu/multimap

Deno

For Deno, the following approach is recommended:

In the root folder of your project, create or edit a file called import_map.json with the following contents (where you should replace x.y.z with the desired version of Rimbu):

{
  "imports": {
    "@rimbu/": "https://deno.land/x/rimbu@x.y.z/"
  }
}

Note: The trailing slashes are important!

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

Usage

import { HashMultiMapHashValue } from '@rimbu/multimap';

console.log(HashMultiMapHashValue.of([1, 2], [1, 3], [2, 3]).toString());

Usage

Author

Created and maintained by Arvid Nicolaas.

Contributing

We welcome contributions! Please read our Contributing guide.

Contributors

Made with contributors-img.

License

This project is licensed under the MIT License. See the LICENSE for details.