|
|
| IndexMap () noexcept(noexcept(map_type()) &&noexcept(vector_type()) &&noexcept(value_vector_type()))=default |
| | Default constructor.
|
| |
| template<typename iter> |
|
| IndexMap (iter first, iter last) |
| | Construct from a range of key-value pairs.
|
| |
|
| IndexMap (const IndexMap &other) |
| | Copy constructor.
|
| |
|
| IndexMap (IndexMap &&other) noexcept |
| | Default move constructor.
|
| |
|
| ~IndexMap ()=default |
| | Default destructor.
|
| |
| IndexMap &
| operator= (const IndexMap &other) |
| | Copy assignment.
|
| |
|
IndexMap &
| operator= (IndexMap &&other) noexcept |
| | Default move assignment.
|
| |
| bool
| empty () const noexcept |
| | Is the map empty.
|
| |
| int
| size () const noexcept |
| | Get the size of the map.
|
| |
|
void
| clear () noexcept |
| | Clear the indexed map.
|
| |
| template<typename K, typename V> |
| int
| insert (K &&key, V &&value) |
| | Insert a key with a value.
|
| |
| template<typename K, typename... V> |
| int
| emplace (K &&key, V &&... value) |
| | Insert a key with a value in-place construction.
|
| |
| template<typename K, typename V> |
| int
| insert_replace (K &&key, V &&value) |
| | Insert a new key with a value or replace a value of an existed key.
|
| |
| bool
| erase (int i) noexcept |
| | Erase the i-th element.
|
| |
| bool
| erase_key (const key_type &key) |
| | Erase a key if it is in the map.
|
| |
| bool
| exchange (int i, int j) noexcept |
| | Exchange the i-th and j-th elements.
|
| |
| bool
| erase_last () noexcept |
| | Erase the last element.
|
| |
| const value_type &
| operator[] (const key_type &key) const |
| | Get the value from a key.
|
| |
| value_type &
| operator[] (const key_type &key) |
| | Get the value from a key.
|
| |
| const value_type &
| operator() (int id) const noexcept |
| | Get the i-th value.
|
| |
| value_type &
| operator() (int id) noexcept |
| | Get the i-th value.
|
| |
| const key_type &
| find_key (int id) const noexcept |
| | Get the i-th key.
|
| |
| bool
| contains (const key_type &key) const |
| | Does the map contain a given key.
|
| |
| int
| index (const key_type &key) const |
| | Get the index of a given key.
|
| |
| template<typename K, typename... T> |
| bool
| set (int i, K &&key, T &&... value) |
| | Set the i-th element by a given key and a given value.
|
| |
| constexpr auto
| begin () noexcept |
| | Get the iterator of the first element.
|
| |
| constexpr auto
| begin () const noexcept |
| | Get the const iterator of the first element.
|
| |
| constexpr auto
| cbegin () const noexcept |
| | Get the const iterator of the first element.
|
| |
| constexpr auto
| end () noexcept |
| | Get the iterator after the last element.
|
| |
| constexpr auto
| end () const noexcept |
| | Get the const iterator after the last element.
|
| |
| constexpr auto
| cend () const noexcept |
| | Get the const iterator after the last element.
|
| |
| constexpr auto
| rbegin () noexcept |
| | Get the reversed iterator of the last element.
|
| |
| constexpr auto
| rbegin () const noexcept |
| | Get the reversed const iterator of the last element.
|
| |
| constexpr auto
| crbegin () const noexcept |
| | Get the reversed const iterator of the last element.
|
| |
| constexpr auto
| rend () noexcept |
| | Get the reversed iterator before the first element.
|
| |
| constexpr auto
| rend () const noexcept |
| | Get the reversed const iterator before the first element.
|
| |
| constexpr auto
| crend () const noexcept |
| | Get the reversed const iterator before the first element.
|
| |
template<class key_type, class value_type, class hasher = std::hash<key_type>, class keyeq = std::equal_to<key_type>>
class AMCAX::IndexMap< key_type, value_type, hasher, keyeq >
Template class of indexed map.
- Template Parameters
-
| key_type | Type of key |
| value_type | Type of value |
| hasher | Type of hasher |
| keyeq | Type of equality operator |
template<class key_type, class value_type, class hasher = std::hash<key_type>, class keyeq = std::equal_to<key_type>>
template<typename K, typename... V>
| int AMCAX::IndexMap< key_type, value_type, hasher, keyeq >::emplace
|
( |
K &&
|
key
,
|
|
|
V &&...
|
value
)
|
|
inline
|
Insert a key with a value in-place construction.
If there is a key in the map equal to the given key, do nothing and return the index of the existed key
- Template Parameters
-
| K | Type of new key |
| ...V | Type of new value |
- Parameters
-
| key | The new key |
| ...value | The new value |
- Returns
- The index of the new key
template<class key_type, class value_type, class hasher = std::hash<key_type>, class keyeq = std::equal_to<key_type>>
template<typename K, typename V>
| int AMCAX::IndexMap< key_type, value_type, hasher, keyeq >::insert
|
( |
K &&
|
key
,
|
|
|
V &&
|
value
)
|
|
inline
|
Insert a key with a value.
If there is a key in the map equal to the given key, do nothing and return the index of the existed key
- Template Parameters
-
| K | Type of new key |
| V | Type of new value |
- Parameters
-
| key | The new key |
| value | The new value |
- Returns
- The index of the new key