|
| const Left & | left () const noexcept |
| const Right & | right () const noexcept |
| size_t | size () const noexcept |
| bool | empty () const noexcept |
| auto | begin () const noexcept |
| auto | end () const noexcept |
at_left() and at_right() throw std::out_of_range if the key is unbound.
|
| bool | contains_left (const auto &l) const |
| bool | contains_right (const auto &r) const |
| const R & | at_left (const auto &l) const |
| const L & | at_right (const auto &r) const |
They take their arguments by value, so a reference into this BiMap cannot dangle halfway through.
|
| bool | insert (L l, R r) |
| | Binds l to r unless either is already bound; yields whether it did.
|
| void | insert_or_assign (L l, R r) |
| | Binds l to r after unbinding whatever either was bound to.
|
| bool | erase_left (const auto &l) |
| | Unbinds l and its partner; yields whether l was bound.
|
| bool | erase_right (const auto &r) |
| | Unbinds r and its partner; yields whether r was bound.
|
| void | reserve (size_t n) |
| void | clear () noexcept |
template<class L, class R, class LHash = ankerl::unordered_dense::hash<L>, class LEq = std::equal_to<L>, class RHash = ankerl::unordered_dense::hash<R>, class REq = std::equal_to<R>>
class fe::BiMap< L, R, LHash, LEq, RHash, REq >
A bijection between L and R, kept as one ankerl::unordered_dense::map per direction.
Look up through left() and right(); a transparent hasher and equality enable heterogeneous lookup there as well. Iterating a BiMap yields its std::pair<L, R>s in left() order.
- Note
- Every pair is stored once per direction, so keep
L and R cheap to copy - a Sym or a pointer, say. Otherwise, or if you need a pair's address to survive an insert, use BiNodeMap.
Definition at line 37 of file bimap.h.
template<class L, class R, class LHash = ankerl::unordered_dense::hash<L>, class LEq = std::equal_to<L>, class RHash = ankerl::unordered_dense::hash<R>, class REq = std::equal_to<R>>
| bool fe::BiMap< L, R, LHash, LEq, RHash, REq >::erase_left |
( |
const auto & | l | ) |
|
|
inline |
template<class L, class R, class LHash = ankerl::unordered_dense::hash<L>, class LEq = std::equal_to<L>, class RHash = ankerl::unordered_dense::hash<R>, class REq = std::equal_to<R>>
| bool fe::BiMap< L, R, LHash, LEq, RHash, REq >::erase_right |
( |
const auto & | r | ) |
|
|
inline |
template<class L, class R, class LHash = ankerl::unordered_dense::hash<L>, class LEq = std::equal_to<L>, class RHash = ankerl::unordered_dense::hash<R>, class REq = std::equal_to<R>>
| bool fe::BiMap< L, R, LHash, LEq, RHash, REq >::insert |
( |
L | l, |
|
|
R | r ) |
|
inline |
Binds l to r unless either is already bound; yields whether it did.
Definition at line 66 of file bimap.h.
template<class L, class R, class LHash = ankerl::unordered_dense::hash<L>, class LEq = std::equal_to<L>, class RHash = ankerl::unordered_dense::hash<R>, class REq = std::equal_to<R>>
| void fe::BiMap< L, R, LHash, LEq, RHash, REq >::insert_or_assign |
( |
L | l, |
|
|
R | r ) |
|
inline |