Dictionary-like data structure representing a bijective map?

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> b = BijectiveMap(:a => 1);

julia> get_value(b, :a)

julia> get_key(b, 1)
1 Like

I found one!

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

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

julia> b[:a]

julia> b(1)