Template Class set_t
Defined in File set.hpp
Inheritance Relationships
Base Type
public std::unordered_set< type >
Class Documentation
-
template<typename type>
class set_t : public std::unordered_set<type> This simple class is used to store unordered sets of data. It is a simple wrapper for the std::unordered_set class, but it uses a shared mutex to lock the access to the set among other useful functions.
Public Types
Shared pointer type.
Public Functions
-
inline set_t()
Empty constructor for the Visualization Set object.
-
inline set_t(type data_)
Construct a new set safe object from a single data point
- Parameters:
data_ – Initial element inserted into the set during construction.
-
inline set_t(const set_t<type> &other_)
Copy constructor
- Parameters:
other_ – Source set to copy from while holding a shared read lock.
-
inline ~set_t()
Destroy the Visualization Set object.
-
inline set_t<type> &operator=(const set_t<type> &other_)
Equal operator
- Parameters:
other_ – Source set whose contents replace the current set.
- Returns:
Reference to this set after the synchronized assignment.
-
inline void insert_(type id_)
Safe add a point to the set.
- Parameters:
id_ – Element to insert while holding the write lock.
-
inline void erase_(type id_)
Safe remove a point from the set.
- Parameters:
id_ – Element to remove while holding the write lock.
-
inline void clear_(const vector_t<type> &itemsToRemove_ = vector_t<type>())
Safe erase multiple points from the set. [all if empty]
- Parameters:
itemsToRemove_ – Elements to erase; when empty, the whole set is cleared.
-
inline bool contains_(const type &value_) const
Safe check if the set contains a specific value.
- Parameters:
value_ – Element to search for in the set.
- Returns:
True when
value_is present, otherwise false.
-
inline void lock_read() const
This function is used to lock the entire set for reading purposes.
-
inline void unlock_read() const
To unlock the set after it was locked for reading.
-
inline void lock() const
This function is used to lock the entire set for writing purposes.
-
inline void unlock() const
To unlock the set after it was locked for writing.
-
inline int get_size_safe() const
Get the size of the set in a thread-safe manner.
- Returns:
Number of elements currently stored in the set.
-
inline std::unordered_set<type> get_all() const
Get all elements in a thread-safe manner.
- Returns:
Copy of the full unordered set at the time of the call.
Public Static Functions
Make shared pointer function
- Returns:
Shared pointer owning a new empty thread-safe unordered set.
Private Members
-
mutable std::shared_mutex _mutex
Mutex that is used to lock the set for reading and writing.