API
The following methods constitute the public API of the Bijections
package.
Index
Bijections.Bijection
Base.delete!
Base.get
Base.getindex
Base.haskey
Base.inv
Base.isempty
Base.length
Base.setindex!
Bijections.active_inv
Bijections.hasvalue
Bijections.inverse
Bijections.inverse_dict_type
Reference
Bijections.Bijection
— MethodBijection()
Construct 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.delete!
— Methoddelete!(b::Bijection, x)
Deletes the ordered pair (x,b[x])
from b
.
Base.get
— Methodget(b::Bijection, key, default)
Returns b[key]
if it exists and returns default
otherwise.
Base.getindex
— Methodgetindex(b::Bijection, x)
For a Bijection
b
and a value x
in its domain, use b[x]
to fetch the image value y
associated with x
.
Base.haskey
— MethodBase.haskey(b::Bijection, x)
Checks if x
is in the domain of the Bijection b
.`
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!
— Methodsetindex!(b::Bijection, y, x)
For 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.hasvalue
— Methodhasvalue(b::Bijection, y)
Checks if y
is in the image of the Bijection b
. It is equivalent to checking if the inverse mapping b.finv
has y
as a key, so it should as fast as haskey
.
Bijections.inverse
— Methodinverse(b::Bijection, y)
Returns the value x
such that b[x] == y
(if it exists).
Bijections.inverse_dict_type
— Methodinverse_dict_type(D::Type{<:AbstractDict})
Returns the type of the inverse dictionary for a given AbstractDict
type D
. This is used internally to create the inverse mapping in a Bijection
.