Datastructure for two-way map

@rikh It seems like you might have overlooked the convenient syntax that Bijections.jl provides for accessing the maps in both directions:

julia> using Bijections

julia> b = Bijection("alpha", 1)
Bijection{String,Int64} (with 1 pairs)

julia> b["alpha"]
1

julia> b(1)
"alpha"

Notice that a Bijection is callable. So, to access the “left” map, you index the bijection, and to access the “right” map, you call the bijection.

The only small downside to this is that there is not much visual distinction between b["a"] and b("a").

5 Likes