Template Class ordered_t
Defined in File set.hpp
Inheritance Relationships
Base Type
public std::set< type >
Class Documentation
-
template<typename type>
class ordered_t : public std::set<type> This simple class is used to store ordered sets of data. It is a simple wrapper for the std::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 ordered_t()
Empty constructor for the Visualization Set object.
-
inline ordered_t(type data_)
Construct a new set safe object from a single data point
- Parameters:
data_ – Initial element inserted into the ordered set during construction.
-
inline ordered_t(const ordered_t<type> &other_)
Copy constructor
- Parameters:
other_ – Source ordered set to copy from while holding a shared read lock.
-
inline ~ordered_t()
Destroy the Visualization Set object.
-
inline ordered_t<type> &operator=(const ordered_t<type> &other_)
Equal operator
- Parameters:
other_ – Source ordered set whose contents replace the current set.
- Returns:
Reference to this ordered set after 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 ordered 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 ordered set.
-
inline std::set<type> get_all() const
Get all elements in a thread-safe manner.
- Returns:
Copy of the full ordered set at the time of the call.
Public Static Functions
Make shared pointer function
- Returns:
Shared pointer owning a new empty thread-safe ordered set.
Private Members
-
mutable std::shared_mutex _mutex
Mutex that is used to lock the set for reading and writing.