Thread-safe wrapper for std::set.
More...
#include <thread_safe_set.hpp>
|
template<typename... Args> |
std::pair< typename std::set< T >::iterator, bool > | emplace (Args &&... args) |
| Constructs an element in-place within the underlying std::set .
|
|
bool | insert (const T &value) |
| Inserts a copy of value into the underlying std::set .
|
|
bool | erase (const T &value) |
| Erases a value from the set if it exists.
|
|
bool | contains (const T &value) const |
| Checks whether the specified value is contained in the set.
|
|
lock_guard | get_lock_guard () const |
| Acquires a lock guard for the set, ensuring thread safety.
|
|
| thread_safe_container ()=default |
| Default constructor.
|
|
virtual | ~thread_safe_container () noexcept |
|
bool | empty () const |
| Checks if the container is empty.
|
|
void | clear () |
| Clears the contents.
|
|
std::size_t | size () const |
| Returns the number of elements.
|
|
auto | begin () |
| Returns an iterator to the beginning.
|
|
auto | end () |
| Returns an iterator to the end.
|
|
bool | is_being_modified () const |
|
template<typename T>
class cbeam::container::thread_safe_set< T >
Thread-safe wrapper for std::set.
- Template Parameters
-
◆ contains()
Checks whether the specified value is contained in the set.
This function acquires a lock to ensure thread safety while searching.
- Parameters
-
value | The value to look for. |
- Returns
true
if the set contains the value, false
otherwise.
◆ emplace()
template<typename T>
template<typename... Args>
Constructs an element in-place within the underlying std::set
.
This function uses perfect forwarding to create an element of type T
directly within the set. It throws a runtime_error
if the set is currently being modified.
- Template Parameters
-
Args | The parameter pack for constructing the T object. |
- Parameters
-
args | Arguments to forward to the constructor of T . |
- Returns
- A
std::pair
containing an iterator to the inserted element and a boolean indicating success/failure.
◆ erase()
Erases a value from the set if it exists.
If the set is currently being modified, a runtime_error
is thrown.
- Parameters
-
- Returns
true
if the value was present and erased, false
otherwise.
◆ insert()
Inserts a copy of value
into the underlying std::set
.
If the set is currently being modified, a runtime_error
is thrown.
- Parameters
-
value | The value to insert into the set. |
- Returns
true
if the insertion was successful, false
if the value already exists.
The documentation for this class was generated from the following file: