27template <
typename Left,
typename Right>
59 typename left_map::iterator
find(
const Left& key)
const {
return map_.find(key); }
62 typename left_map::iterator
end()
const {
return map_.end(); }
66 const Right&
at(
const Left& key)
const {
return map_.at(key); }
78 typename right_map::iterator
find(
const Right& key)
const {
return map_.find(key); }
81 typename right_map::iterator
end()
const {
return map_.end(); }
85 const Left&
at(
const Right& key)
const {
return map_.at(key); }
127 throw std::out_of_range(
"Key not found in left map");
138 throw std::out_of_range(
"Key not found in right map");
147template <
typename Left,
typename Right>
151 for (
const auto& rel : relations) {
152 bimap.
insert(rel.left, rel.right);
BiMap< Left, Right > make_bimap(std::initializer_list< typename BiMap< Left, Right >::relation > relations)
Helper function to create a BiMap from an initializer list.
Simple bidirectional map with lookup in both directions.
void insert(const Left &left, const Right &right)
Insert or overwrite a left/right association.
right_map::iterator right_find(const Right &key)
Find an entry by right key.
right_view right
Right view accessor.
const Left & right_at(const Right &key) const
Get mapped left value by right key (throws if missing).
std::map< Left, Right > left_map
std::map< Right, Left > right_map
left_view left
Left view accessor.
BiMap()
Construct an empty bimap.
const Right & left_at(const Left &key) const
Get mapped right value by left key (throws if missing).
right_map::iterator right_end()
End iterator for right map.
left_map::iterator left_find(const Left &key)
Find an entry by left key.
left_map::iterator left_end()
End iterator for left map.
Left-map view with find/at helpers.
left_map::iterator end() const
End iterator for the left map.
left_map::iterator find(const Left &key) const
Find iterator for key in the left map.
const Right & at(const Left &key) const
Get mapped value by key (throws if missing).
left_view(left_map &m)
Construct a left view from a map reference.
Pair relation used for initialization.
relation(const Left &l, const Right &r)
Construct a relation from left/right values.
Right-map view with find/at helpers.
right_map::iterator find(const Right &key) const
Find iterator for key in the right map.
right_view(right_map &m)
Construct a right view from a map reference.
right_map::iterator end() const
End iterator for the right map.
const Left & at(const Right &key) const
Get mapped value by key (throws if missing).