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
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
can also be mapped to a unique
. A pair
thus provides a
unique coupling between
and
so that
can be found when
is used as a key and
can be found when
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 ...
between two different sets of keys
and
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:
External links
Boost.orgCodeproject.combidict (bidirectional map implementation for Python)
Associative arrays
{{datastructure-stub