AMCAX Kernel 1.0.0.0
|
Template class of bidirectional map. More...
#include <common/Bimap.hpp>
Public Member Functions | |
Bimap ()=default | |
Default constructor. | |
Bimap (const std::unordered_map< key_type, value_type > &smap) | |
Construct from a normal map. More... | |
bool | empty () const noexcept |
Is the map empty. More... | |
int | size () const noexcept |
Get the size of map. More... | |
void | clear () |
Clear the map. | |
bool | insert (const key_type &key, const value_type &value) |
Insert a pair of key and value. More... | |
bool | insert_replace (const key_type &key, const value_type &value) |
Insert a pair of key and value, replace the data if existed. More... | |
bool | erase_key (const key_type &key) |
Erase the data by key. More... | |
map_iterator1 | erase_key (map_iterator1 it) |
Erase the data by iterator of forward map. More... | |
map_iterator1 | erase_key (map_const_iterator1 it) |
Erase the data by constant iterator of forward map. More... | |
bool | erase_value (const value_type &value) |
Erase the data by value. More... | |
map_iterator2 | erase_value (map_iterator2 it) |
Erase the data by iterator of inverse map. More... | |
map_iterator2 | erase_value (map_const_iterator2 it) |
Erase the data by constant iterator of inverse map. More... | |
void | swap (Bimap &other) |
Swap with another bimap. More... | |
std::pair< map_const_iterator1, bool > | find_value_from_key (const key_type &k) const |
Find the value from a key. More... | |
std::pair< map_const_iterator2, bool > | find_key_from_value (const value_type &v) const |
Find the key from a value. More... | |
constexpr auto | begin () noexcept |
Get the begin iterator. More... | |
constexpr auto | begin () const noexcept |
Get the constant begin iterator. More... | |
constexpr auto | cbegin () const noexcept |
Get the constant begin iterator. More... | |
constexpr auto | end () noexcept |
Get the end iterator. More... | |
constexpr auto | end () const noexcept |
Get the constant end iterator. More... | |
constexpr auto | cend () const noexcept |
Get the constant end iterator. More... | |
constexpr auto & | inverse_map () const noexcept |
Get the inverse map. More... | |
Protected Attributes | |
map_type1 | map1 |
Map from key to value. | |
map_type2 | map2 |
Map from value to key. | |
Template class of bidirectional map.
key_type | Type of key |
value_type | Type of value |
|
inlineexplicit |
Construct from a normal map.
smap | The map |
|
inlineconstexprnoexcept |
Get the constant begin iterator.
|
inlineconstexprnoexcept |
Get the begin iterator.
|
inlineconstexprnoexcept |
Get the constant begin iterator.
|
inlineconstexprnoexcept |
Get the constant end iterator.
|
inlinenoexcept |
Is the map empty.
|
inlineconstexprnoexcept |
Get the constant end iterator.
|
inlineconstexprnoexcept |
Get the end iterator.
|
inline |
Erase the data by key.
key | The key to be erased |
|
inline |
Erase the data by constant iterator of forward map.
it | The constant iterator of forward map |
|
inline |
Erase the data by iterator of forward map.
it | The iterator of forward map |
|
inline |
Erase the data by value.
value | The value to be erased |
|
inline |
Erase the data by constant iterator of inverse map.
it | The constant iterator of inverse map |
|
inline |
Erase the data by iterator of inverse map.
it | The iterator of inverse map |
|
inline |
Find the key from a value.
v | The value |
|
inline |
Find the value from a key.
k | The key |
|
inline |
Insert a pair of key and value.
If either the key or the value is found in the map, do nothing
key | The key to be inserted |
value | The value to be inserted |
|
inline |
Insert a pair of key and value, replace the data if existed.
If the key and value are both found in the map, but not mapped to each other, the insertion fails.
key | The key to be inserted |
value | The value to be inserted |
|
inlineconstexprnoexcept |
Get the inverse map.
|
inlinenoexcept |
Get the size of map.
|
inline |
Swap with another bimap.
other | The other bimap |