# Dictionary-like data structure representing a bijective map?

**URL:** <https://discourse.julialang.org/t/dictionary-like-data-structure-representing-a-bijective-map/45341>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 21, 2020, 10:10pm UTC](https://discourse.julialang.org/t/dictionary-like-data-structure-representing-a-bijective-map/45341 "2020-08-21T22:10:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [August 21, 2020, 10:10pm UTC](https://discourse.julialang.org/t/dictionary-like-data-structure-representing-a-bijective-map/45341/1 "2020-08-21T22:10:58Z")

</div>

Does anyone know of a dictionary-like data structure that represents a bijective (_one-to-one_ and _onto_) map? And if so, is there a Julia implementation of such a data structure?

Ideally this data structure would have a method for getting a key given a value (in addition to the usual method for getting a value given a key).

So the interface might look something like this:

```julia
julia> b = BijectiveMap(:a => 1);

julia> get_value(b, :a)
1

julia> get_key(b, 1)
:a

```

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [August 21, 2020, 10:17pm UTC](https://discourse.julialang.org/t/dictionary-like-data-structure-representing-a-bijective-map/45341/2 "2020-08-21T22:17:10Z")

</div>

I found one!

[https://github.com/scheinerman/Bijections.jl](https://github.com/scheinerman/Bijections.jl)

For reference, here’s the syntax used by Bijections.jl:

```julia
julia> b = Bijection(:a, 1)
Bijection{Symbol,Int64} (with 1 pairs)

julia> b[:a]
1

julia> b(1)
:a

```
