Construct a new Bijection.

  • Bijection{S,T}() creates an empty Bijection from objects of type S to objects of type T. If S and T are omitted, then we have Bijection{Any,Any}.
  • Bijection(x::S, y::T) creates a new Bijection initialized with x mapping to y.
  • Bijection(dict::Dict{S,T}) creates a new Bijection based on the mapping in dict.
  • Bijection(pair_list::Vector{Pair{S,T}}) creates a new Bijection using the key/value pairs in pair_list.
(*)(a::Bijection{A,B}, b::Bijection{B,C})::Bijection{A,C} where {A,B,C}

The result of a * b is a new Bijection c such that c[x] is a[b[x]] for x in the domain of b. This function throws an error is domain(a) is not the same as the image of b.


delete!(b::Bijection,x) deletes the ordered pair (x,b[x]) from b.1==


get(b::Bijection, key, default) returns b[key] if it exists and returns default otherwise.


For a Bijection b and a value x in its domain, use b[x] to fetch the image value y associated with x.


inv(b::Bijection) creates a new Bijection that is the inverse of b. Subsequence changes to b will not affect inv(b).

See also active_inv.


isempty(b::Bijection) returns true iff b has no pairs.


length(b::Bijection) gives the number of ordered pairs in b.


For a Bijection b use the syntax b[x]=y to add (x,y) to b.


active_inv(b::Bijection) creates a Bijection that is the inverse of b. The original b and the new Bijection returned are tied together so that changes to one immediately affect the other. In this way, the two Bijections remain inverses in perpetuity.

See also inv.


domain(b::Bijection) returns the set of input values for b.


image(b::Bijection) returns the set of output values of b.


inverse(b::Bijection,y) returns the value x such that b[x] == y (if it exists).