View Source BiMap

Build Status Version Hex Docs Download License Last Updated

Elixir implementation of bidirectional map (BiMap) and multimap (BiMultiMap).

installation

Installation

The package can be installed by adding bimap to your list of dependencies in mix.exs:

def deps do
  [{:bimap, "~> 1.2"}]
end

getting-started

Getting started

For more examples, checkout BiMap and BiMultiMap on hex docs.

bimap

BiMap

iex(1)> Mix.install [:bimap]
iex(2)> bm = BiMap.new(a: 1, b: 2)
#BiMap<[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<[a: 3, b: 2]>
iex(6)> BiMap.put(bm, :c, 2)
#BiMap<[a: 1, c: 2]>

bimultimap

BiMultiMap

iex(1)> Mix.install [:bimap]
iex(2)> mm = BiMultiMap.new(a: 1, b: 2, b: 1)
#BiMultiMap<[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<[a: 1, a: 3, b: 1, b: 2]>

changelog

Changelog

All notable changes to this project are documented on the GitHub releases page.

license

License

See the LICENSE file for license rights and limitations (MIT).