Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mkaput/elixir-bimap
Elixir implementation of bidirectional map and multimap
https://github.com/mkaput/elixir-bimap
bimap bimultimap data-structures elixir
Last synced: about 1 month ago
JSON representation
Elixir implementation of bidirectional map and multimap
- Host: GitHub
- URL: https://github.com/mkaput/elixir-bimap
- Owner: mkaput
- License: mit
- Created: 2017-08-10T20:15:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-01-23T09:45:15.000Z (11 months ago)
- Last Synced: 2024-10-19T11:16:01.861Z (about 2 months ago)
- Topics: bimap, bimultimap, data-structures, elixir
- Language: Elixir
- Homepage:
- Size: 102 KB
- Stars: 27
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Pure Elixir implementation of [bidirectional maps](https://en.wikipedia.org/wiki/Bidirectional_map) and multimaps. (Algorithms and Data structures)
- fucking-awesome-elixir - bimap - Pure Elixir implementation of [bidirectional maps](https://en.wikipedia.org/wiki/Bidirectional_map) and multimaps. (Algorithms and Data structures)
- awesome-elixir - bimap - Pure Elixir implementation of [bidirectional maps](https://en.wikipedia.org/wiki/Bidirectional_map) and multimaps. (Algorithms and Data structures)
README
# BiMap
[![Version](https://img.shields.io/hexpm/v/bimap.svg)](https://hex.pm/packages/bimap)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/bimap/)Elixir implementation of bidirectional map (`BiMap`) and multimap (`BiMultiMap`).
## Installation
The package can be installed by adding `bimap` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[{:bimap, "~> 1.3"}]
end
```## Getting started
For more examples, checkout [`BiMap`](https://hexdocs.pm/bimap/BiMap.html) and [`BiMultiMap`](https://hexdocs.pm/bimap/BiMultiMap.html) on hex docs.
### BiMap
```elixir
iex(1)> Mix.install [:bimap]
iex(2)> bm = BiMap.new(a: 1, b: 2)
BiMap.new([a: 1, b: 2])
iex(3)> BiMap.get(bm, :a)
1
iex(4)> BiMap.get_key(bm, 2)
:b
iex(5)> BiMap.put(bm, :a, 3)
BiMap.new([a: 3, b: 2])
iex(6)> BiMap.put(bm, :c, 2)
BiMap.new([a: 1, c: 2])
```### BiMultiMap
```elixir
iex(1)> Mix.install [:bimap]
iex(2)> mm = BiMultiMap.new(a: 1, b: 2, b: 1)
BiMultiMap.new([a: 1, b: 1, b: 2])
iex(3)> BiMultiMap.get(mm, :a)
[1]
iex(4)> BiMultiMap.get_keys(mm, 1)
[:a, :b]
iex(5)> BiMultiMap.put(mm, :a, 3)
BiMultiMap.new([a: 1, a: 3, b: 1, b: 2])
```## Changelog
All notable changes to this project are documented on the [GitHub releases] page.
## License
See the [LICENSE] file for license rights and limitations (MIT).
[github releases]: https://github.com/mkaput/elixir-bimap/releases
[license]: https://github.com/mkaput/elixir-bimap/blob/master/LICENSE.txt