|
|
using | map_type1 = std::unordered_map<key_type, value_type> |
| | Type of the forward map.
|
| |
|
using | map_type2 = std::unordered_map<value_type, key_type> |
| | Type of the inverse map.
|
| |
|
using | map_iterator1 = typename map_type1::iterator |
| | Iterator of the forward map.
|
| |
|
using | map_iterator2 = typename map_type2::iterator |
| | Iterator of the inverse map.
|
| |
|
using | map_const_iterator1 = typename map_type1::const_iterator |
| | Constant iterator of the forward map.
|
| |
|
using | map_const_iterator2 = typename map_type2::const_iterator |
| | Constant iterator of the inverse map.
|
| |
|
|
| Bimap () noexcept(noexcept(map_type1()) &&noexcept(map_type2()))=default |
| | Default constructor.
|
| |
| | Bimap (const std::unordered_map< key_type, value_type > &smap) |
| | Construct from a normal map.
|
| |
| bool | empty () const noexcept |
| | Is the map empty.
|
| |
| int | size () const noexcept |
| | Get the size of map.
|
| |
|
void | clear () noexcept |
| | Clear the map.
|
| |
| bool | insert (const key_type &key, const value_type &value) |
| | Insert a pair of key and value.
|
| |
| bool | insert_replace (const key_type &key, const value_type &value) |
| | Insert a pair of key and value, replace the data if existed.
|
| |
| bool | erase_key (const key_type &key) |
| | Erase the data by key.
|
| |
| map_iterator1 | erase_key (map_iterator1 it) noexcept |
| | Erase the data by iterator of forward map.
|
| |
| map_iterator1 | erase_key (map_const_iterator1 it) noexcept |
| | Erase the data by constant iterator of forward map.
|
| |
| bool | erase_value (const value_type &value) |
| | Erase the data by value.
|
| |
| map_iterator2 | erase_value (map_iterator2 it) noexcept |
| | Erase the data by iterator of inverse map.
|
| |
| map_iterator2 | erase_value (map_const_iterator2 it) noexcept |
| | Erase the data by constant iterator of inverse map.
|
| |
| void | swap (Bimap &other) noexcept(noexcept(std::declval< map_type1 >().swap(other.map1)) &&noexcept(std::declval< map_type2 >().swap(other.map2))) |
| | Swap with another bimap.
|
| |
| std::pair< map_const_iterator1, bool > | find_value_from_key (const key_type &k) const |
| | Find the value from a key.
|
| |
| std::pair< map_const_iterator2, bool > | find_key_from_value (const value_type &v) const |
| | Find the key from a value.
|
| |
| constexpr auto | begin () noexcept |
| | Get the begin iterator.
|
| |
| constexpr auto | begin () const noexcept |
| | Get the constant begin iterator.
|
| |
| constexpr auto | cbegin () const noexcept |
| | Get the constant begin iterator.
|
| |
| constexpr auto | end () noexcept |
| | Get the end iterator.
|
| |
| constexpr auto | end () const noexcept |
| | Get the constant end iterator.
|
| |
| constexpr auto | cend () const noexcept |
| | Get the constant end iterator.
|
| |
| constexpr auto & | inverse_map () const noexcept |
| | Get the inverse map.
|
| |
template<typename key_type, typename value_type>
class AMCAX::Bimap< key_type, value_type >
Template class of bidirectional map.
- Template Parameters
-
| key_type | Type of key |
| value_type | Type of value |
template<typename key_type, typename value_type>
| bool AMCAX::Bimap< key_type, value_type >::insert_replace |
( |
const key_type & | key, |
|
|
const value_type & | value ) |
|
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.
- Parameters
-
| key | The key to be inserted |
| value | The value to be inserted |
- Returns
- True if the insertion succeed