API

The following methods constitute the public API of the Bijections package.

Index

Reference

Bijections.BijectionMethod
Bijection()

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.
source
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.

source
Base.delete!Method
delete!(b::Bijection, x)

Deletes the ordered pair (x,b[x]) from b.

source
Base.getMethod
get(b::Bijection, key, default)

Returns b[key] if it exists and returns default otherwise.

source
Base.getindexMethod
getindex(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.

source
Base.haskeyMethod
Base.haskey(b::Bijection, x)

Checks if x is in the domain of the Bijection b.`

source
Base.invMethod
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.

source
Base.lengthMethod
length(b::Bijection)

Gives the number of ordered pairs in b.

source
Base.setindex!Method
setindex!(b::Bijection, y, x)

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

source
Bijections.active_invMethod
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.

source
Bijections.hasvalueMethod
hasvalue(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.

source
Bijections.inverse_dict_typeMethod
inverse_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.

source