21 #ifndef LUNCHBOX_LFVECTOR_H 22 #define LUNCHBOX_LFVECTOR_H 25 #include <lunchbox/bitOperation.h> 26 #include <lunchbox/debug.h> 27 #include <lunchbox/os.h> 28 #include <lunchbox/scopedMutex.h> 29 #include <lunchbox/serializable.h> 30 #include <lunchbox/spinLock.h> 53 template <
class T,
int32_t nSlots = 32>
57 using ScopedWrite = std::unique_lock<SpinLock>;
67 LFVector(
const size_t n,
const T& t);
73 template <
int32_t fromSlots>
80 LFVector&
operator=(
const LFVector& from);
86 bool operator!=(
const LFVector& rhs)
const {
return !(*
this == rhs); }
87 bool empty()
const {
return size_ == 0; }
88 size_t size()
const {
return size_; }
107 const_iterator
begin()
const;
108 const_iterator
end()
const;
129 void expand(
const size_t newSize,
const T& item = T());
144 void push_back(
const T& item,
bool lock =
true);
198 iterator
erase(
const T& element);
210 void resize(
const size_t size,
const T& value = T());
232 template <
int32_t fromSlots>
235 void push_back_unlocked_(
const T& item);
242 std::ostream& operator<<(std::ostream& os, const LFVector<T>& v);
245 #include "lfVector.ipp" 247 #endif // LUNCHBOX_LFVECTOR_H An iterator for LFVector.
A fast lock for uncontended memory access.
STL-like vector implementation providing certain thread-safety guarantees.
LFVector & operator=(const LFVector &from)
void push_back(const T &item, bool lock=true)
Add an element to the vector.
ScopedWrite getWriteLock()
LFVectorIterator< LFVector< T, nSlots >, T > iterator
Iterator over the vector elements.
LFVectorIterator< const LFVector< T, nSlots >, const T > const_iterator
Iterator over the const vector elements.
bool operator==(const LFVector &rhs) const
void pop_back()
Remove the last element (STL version).
void clear()
Clear the vector and all storage.
const_iterator end() const
bool operator!=(const LFVector &rhs) const
Abstraction layer and common utilities for multi-threaded programming.
void resize(const size_t size, const T &value=T())
Resize the vector.
void expand(const size_t newSize, const T &item=T())
Resize the vector to at least the given size.
const_iterator begin() const
iterator erase(typename LFVector< T, nSlots >::iterator pos)
Remove an element.