xentara-utils v2.0.4
The Xentara Utility Library
|
A map that can be traversed without locking. More...
#include <xentara/utils/lockFree/LockFreeTraversableMap.hpp>
Classes | |
class | Iterator |
class | Traverser |
Public Types | |
using | value_type = Element |
The value type. | |
using | key_type = std::remove_cvref_t< InternalKey > |
The key type. | |
using | mapped_type = Element |
The element type. | |
using | iterator = Iterator |
An iterator. | |
Public Member Functions | |
LockFreeTraversableMap ()=default | |
Default constructor. | |
internal auto | operator= (LockFreeTraversableMap &&other) noexcept -> LockFreeTraversableMap & |
Move-assignment operator. | |
template<typename Key , typename... Arguments> requires std::constructible_from<Element, Arguments &&...> | |
auto | try_emplace (const Key &key, Arguments &&...arguments) -> std::pair< iterator, bool > |
Emplaces an element with a certain key. | |
template<typename Key > | |
auto | find (const Key &key) -> iterator |
Finds the element with a certain key. | |
auto | erase (iterator position) -> iterator |
Removes the element an iterator points to. | |
auto | empty () const noexcept -> bool |
Checks if the map is empty. | |
auto | end () noexcept -> iterator |
Gets the end iterator. | |
auto | traverse () const noexcept -> Traverser |
Gets a traverser for traversing the list in a lock-free manner. | |
template<typename KeyArgument > | |
auto | find (const KeyArgument &key) -> iterator |
A map that can be traversed without locking.
The key for the map must be part of Element, and there must be a function key(const Element &) findable by argument depended lookup that returns the key.
This class can be moved but not copied.
using xentara::utils::lockFree::LockFreeTraversableMap< Element >::iterator = Iterator |
An iterator.
using xentara::utils::lockFree::LockFreeTraversableMap< Element >::key_type = std::remove_cvref_t<InternalKey> |
The key type.
using xentara::utils::lockFree::LockFreeTraversableMap< Element >::mapped_type = Element |
The element type.
using xentara::utils::lockFree::LockFreeTraversableMap< Element >::value_type = Element |
The value type.
|
default |
Default constructor.
|
noexcept |
Checks if the map is empty.
|
noexcept |
Gets the end iterator.
auto xentara::utils::lockFree::LockFreeTraversableMap< Element >::erase | ( | iterator | position | ) | -> iterator |
Removes the element an iterator points to.
auto xentara::utils::lockFree::LockFreeTraversableMap< Element >::find | ( | const Key & | key | ) | -> iterator |
Finds the element with a certain key.
key | The key to look for. |
auto xentara::utils::lockFree::LockFreeTraversableMap< Element >::find | ( | const KeyArgument & | key | ) | -> iterator |
|
noexcept |
Move-assignment operator.
|
noexcept |
Gets a traverser for traversing the list in a lock-free manner.
All operations on the traverser are automatically thread-synchronized with try_emplace(), find(), and erase().
auto xentara::utils::lockFree::LockFreeTraversableMap< Element >::try_emplace | ( | const Key & | key, |
Arguments &&... | arguments | ||
) | -> std::pair<iterator, bool> |
Emplaces an element with a certain key.
key | The key that the element will have once it is constructed. |
arguments | The arguments to pass to the constructor if an element is constructed. Must construct an element with a key that compares equal to key. |