A concurrent map container which can be stored in persistent memory. This container does not allocate mutex objects internally, but allocates them as static objects. To achieve high concurrency, this container allocates multiple banks, where a bank consists of an actual STL map object and a mutex object. More...
#include </home/runner/work/metall/metall/include/metall/container/concurrent_map.hpp>
Public Types | |
using | key_type = typename internal_map_type::key_type |
A key type. | |
using | mapped_type = typename internal_map_type::mapped_type |
A mapped type. | |
using | value_type = typename internal_map_type::value_type |
A value type (i.e., std::pair<const key_type, mapped_type>). | |
using | size_type = typename internal_map_type::size_type |
A unsigned integer type (usually std::size_t). | |
using | allocator_type = _allocator |
An allocator type. | |
using | const_iterator = metall::utility::container_of_containers_iterator_adaptor< typename banked_map_type::const_iterator, typename internal_map_type::const_iterator > |
A const iterator type. | |
Public Member Functions | |
concurrent_map (const _allocator &allocator=_allocator()) | |
size_type | count (const key_type &key) const |
Returns the number of elements matching specific key. | |
size_type | size () const |
Returns the number of elements in the container. | |
bool | insert (value_type &&value) |
Inserts element into the container if the container doesn't already contain an element with an equivalent key. | |
std::pair< mapped_type &, std::unique_lock< std::mutex > > | scoped_edit (const key_type &key) |
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key. | |
void | edit (const key_type &key, const std::function< void(mapped_type &mapped_value)> &editor) |
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key. | |
const_iterator | cbegin () const |
Returns an iterator to the first element of the map. If the container is empty, the returned iterator will be equal to end(). | |
const_iterator | cend () const |
Returns an iterator to the element following the last element of the map. This element acts as a placeholder; attempting to access it results in undefined behavior. | |
const_iterator | find (const key_type &key) const |
Finds an element with an equivalent key. | |
allocator_type | get_allocator () const |
Returns the allocator associated with the container. | |
A concurrent map container which can be stored in persistent memory. This container does not allocate mutex objects internally, but allocates them as static objects. To achieve high concurrency, this container allocates multiple banks, where a bank consists of an actual STL map object and a mutex object.
_key_type | A key type. |
_mapped_type | A mapped type. |
_compare | A key compare. |
_bank_no_hasher | A key hasher. |
_allocator | An allocator. |
k_num_banks | The number of banks to be allocated. |
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::key_type = typename internal_map_type::key_type |
A key type.
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::mapped_type = typename internal_map_type::mapped_type |
A mapped type.
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::value_type = typename internal_map_type::value_type |
A value type (i.e., std::pair<const key_type, mapped_type>).
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::size_type = typename internal_map_type::size_type |
A unsigned integer type (usually std::size_t).
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::allocator_type = _allocator |
An allocator type.
using metall::container::concurrent_map< _key_type, _mapped_type, _compare, _bank_no_hasher, _allocator, k_num_banks >::const_iterator = metall::utility::container_of_containers_iterator_adaptor< typename banked_map_type::const_iterator, typename internal_map_type::const_iterator> |
A const iterator type.
|
inlineexplicit |
|
inline |
Returns the number of elements matching specific key.
key | A key value of the elements to count. |
|
inline |
Returns the number of elements in the container.
|
inline |
Inserts element into the container if the container doesn't already contain an element with an equivalent key.
value | An element value to insert. |
|
inline |
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key.
key | A key of the element to edit. |
|
inline |
Provides a way to edit an element exclusively. If no element exists with an equivalent key, this container creates a new element with key.
key | A key of the element to edit. |
editor | A function object which edits an element. |
|
inline |
Returns an iterator to the first element of the map. If the container is empty, the returned iterator will be equal to end().
|
inline |
Returns an iterator to the element following the last element of the map. This element acts as a placeholder; attempting to access it results in undefined behavior.
|
inline |
Finds an element with an equivalent key.
key | A key value of the element to search for |
|
inline |
Returns the allocator associated with the container.