BiMap

Bidirectional map between key-and-values of type X and Y inspired by C++ Boost Bimap (boost::bimap).

Members

Aliases

LeftMap
alias LeftMap = Map!(X, Y)
Undocumented in source.
RightMap
alias RightMap = Map!(Y, X)
Undocumented in source.

Functions

clear
void clear()

Clear contents.

contains
bool contains(X x, Y y)

Check if (x, y) is stored.

empty
bool empty()

Check if empty.

insert
void insert(X x, Y y)

Insert (x, y).

left
const(LeftMap) left()

Access to left map must be non-mutating.

length
size_t length()

Get length.

right
const(RightMap) right()

Access to right map must be non-mutating.

Examples

test with builtin associative arrays

alias HashMap(Key, Value) = Value[Key];
BiMap!(size_t, string, HashMap) bm;

bm.insert(42, "42");

assert(bm.left.length == 1);
assert(bm.right.length == 1);

assert(bm.contains(42, "42"));

bm.clear();
assert(bm.empty);

See Also

Meta