HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, information, and automation. Computer science spans Theoretical computer science, theoretical disciplines (such as algorithms, theory of computation, and information theory) to Applied science, ...
, a bidirectional map is an associative data structure in which the (key, value) pairs form a one-to-one correspondence. Thus the
binary relation In mathematics, a binary relation associates some elements of one Set (mathematics), set called the ''domain'' with some elements of another set called the ''codomain''. Precisely, a binary relation over sets X and Y is a set of ordered pairs ...
is functional in each direction: each value can also be mapped to a unique key. A pair (a, b) thus provides a unique coupling between a and b so that b can be found when a is used as a key and a can be found when b is used as a key. Mathematically, a bidirectional map can be defined a
bijection In mathematics, a bijection, bijective function, or one-to-one correspondence is a function between two sets such that each element of the second set (the codomain) is the image of exactly one element of the first set (the domain). Equival ...
f: X \to Y between two different sets of keys X and Y of equal
cardinality The thumb is the first digit of the hand, next to the index finger. When a person is standing in the medical anatomical position (where the palm is facing to the front), the thumb is the outermost digit. The Medical Latin English noun for thum ...
, thus constituting an injective and surjective function: \begin & \forall x, x' \in X, f(x) = f(x') \Rightarrow x = x' \\ & \forall y \in Y, \exists x \in X : y=f(x) \end \Rightarrow \exists f^(x)


External links


Boost.org





Codeproject.com



bidict (bidirectional map implementation for Python)
Associative arrays {{datastructure-stub