Bijections.Bijection
— MethodConstruct a new Bijection
.
Bijection{S,T}()
creates an emptyBijection
from objects of typeS
to objects of typeT
. IfS
andT
are omitted, then we haveBijection{Any,Any}
.Bijection(x::S, y::T)
creates a newBijection
initialized withx
mapping toy
.Bijection(dict::Dict{S,T})
creates a newBijection
based on the mapping indict
.Bijection(pair_list::Vector{Pair{S,T}})
creates a newBijection
using the key/value pairs inpair_list
.
Base.:*
— Method(*)(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
.
Base.delete!
— Methoddelete!(b::Bijection,x)
deletes the ordered pair (x,b[x])
from b
.1==
Base.get
— Methodget(b::Bijection, key, default)
returns b[key] if it exists and returns default otherwise.
Base.getindex
— MethodFor a Bijection
b
and a value x
in its domain, use b[x]
to fetch the image value y
associated with x
.
Base.inv
— Methodinv(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
.
Base.isempty
— Methodisempty(b::Bijection)
returns true iff b
has no pairs.
Base.length
— Methodlength(b::Bijection)
gives the number of ordered pairs in b
.
Base.setindex!
— MethodFor a Bijection
b
use the syntax b[x]=y
to add (x,y)
to b
.
Bijections.active_inv
— Methodactive_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 Bijection
s remain inverses in perpetuity.
See also inv
.
Bijections.domain
— Methoddomain(b::Bijection)
returns the set of input values for b
.
Bijections.image
— Methodimage(b::Bijection)
returns the set of output values of b
.
Bijections.inverse
— Methodinverse(b::Bijection,y)
returns the value x
such that b[x] == y
(if it exists).