Template Class vector_t
Defined in File vector.hpp
Inheritance Relationships
Base Type
public std::vector< type >
Class Documentation
-
template<typename type>
class vector_t : public std::vector<type> Thread-safe wrapper around
std::vector.This container is used across SLAM modules and protects concurrent access with a shared mutex.
Public Types
Shared pointer type.
Public Functions
-
inline vector_t()
Empty constructor for the Visualization Vector object.
-
inline vector_t(type data_)
Constructor with initial data
- Parameters:
data_ – First element inserted during construction.
-
inline vector_t(const vector_t<type> &other_)
Copy constructor
- Parameters:
other_ – Source vector copied while holding a shared read lock.
-
inline ~vector_t()
Destroy the Visualization Vector object.
-
inline vector_t<type> &operator=(const vector_t<type> &other_)
Equal operator
- Parameters:
other_ – Source vector whose contents replace the current vector.
- Returns:
Reference to this vector after synchronized assignment.
-
inline vector_t<type> &operator=(std::vector<type> other_)
Assignment operator from std::vector
- Parameters:
other_ – Standard vector copied into this container.
- Returns:
Reference to this vector after assignment.
-
inline void push_back_(type item_)
Add new item to the vector in a thread-safe manner
- Parameters:
item_ – Element appended to the end of the vector.
-
inline void clear_(const std::vector<type> &itemsToRemove_ = std::vector<type>())
Remove specific items from the vector in a thread-safe manner
- Parameters:
itemsToRemove_ – Elements to erase; empty input clears all elements.
-
inline void clear_(type itemToRemove_)
Remove a specific item from the vector in a thread-safe manner
- Parameters:
itemToRemove_ – Element value to erase from the vector.
-
inline type at_(size_t pos_)
Access an element in a thread-safe manner
- Parameters:
pos_ – Zero-based index of the element to read.
- Returns:
Copy of the element stored at
pos_.
-
inline void assign_(typename vector_t<type>::const_iterator first_, typename vector_t<type>::const_iterator last_)
Assign from iterators in a thread-safe manner
- Parameters:
first_ – Iterator to the first element of the source range.
last_ – Iterator one past the last element of the source range.
This function is used to lock the entire vector for reading.
This function is used to unlock the vector after it was.
-
inline void unique_lock() const
This function is used to lock the entire vector for writing.
-
inline void unlock_unique() const
This function is used to unlock the vector after it was.
-
inline int get_size_safe() const
Get the size of the vector in a thread-safe manner
- Returns:
Number of elements currently stored in the vector.
Public Static Functions
Make shared pointer function
- Returns:
Shared pointer owning a new empty thread-safe vector.
Make shared pointer function from data
- Parameters:
data_ – Initial contents copied into the new shared vector.
- Returns:
Shared pointer owning a copy of
data_.
Make shared pointer function from std::vector
- Parameters:
data_ – Initial standard vector contents to copy.
- Returns:
Shared pointer owning a vector initialized from
data_.
Private Members
-
mutable std::shared_mutex _mutex
Mutex that is used to lock the vector for reading and writing.