Devel Lib
Devel::Threading::CMutexVector< T > Class Template Reference

Public Types

typedef std::function< bool(const T &)> FnMatch
 

Public Member Functions

 CMutexVector ()=default
 Default constructor for CMutexVector.
 
 CMutexVector (std::vector< T > &i_oVector)
 Copy constructor that takes a non-const reference to a vector.
 
 CMutexVector (std::vector< T > &&i_oVector)
 Move constructor that takes an rvalue reference to a vector.
 
 CMutexVector (const CMutexVector< T > &i_oVector)
 Copy constructor that takes a const reference to another CMutexVector.
 
 CMutexVector (CMutexVector< T > &&i_oVector) noexcept
 
virtual ~CMutexVector ()=default
 Destructor for CMutexVector.
 
bool removeAll (FnMatch i_fnMatch)
 Removes all elements from the vector that match the given condition. More...
 
bool removeOne (FnMatch i_fnMatch)
 Removes the first element from the vector that matches the given condition. More...
 
bool remove (FnMatch i_fnMatch)
 Removes the first element from the vector that matches the given condition. More...
 
find (FnMatch i_fnMatch) const
 Finds the first element in the vector that matches the given condition. More...
 
get (FnMatch i_fnMatch) const
 Alias for find(FnMatch). More...
 
std::vector< T > findAll (FnMatch i_fnMatch) const
 Finds all elements in the vector that match the given condition. More...
 
std::vector< T > getAll (FnMatch i_fnMatch) const
 Alias for findAll(FnMatch). More...
 
size_t findIndex (FnMatch i_fnMatch) const
 Finds the index of the first element in the vector that matches the given condition. More...
 
size_t indexOf (FnMatch i_fnMatch) const
 Alias for findIndex(FnMatch). More...
 
std::vector< size_t > findIndexAll (FnMatch i_fnMatch) const
 Finds all indexes of the elements in the vector that match the given condition. More...
 
std::vector< size_t > indexOfAll (FnMatch i_fnMatch) const
 Alias for findIndexAll(FnMatch). More...
 
take (FnMatch i_fnMatch) const
 Takes the first element from the vector that matches the given condition and removes it from the vector. More...
 
std::vector< T > takeAll (FnMatch i_fnMatch) const
 Takes all elements from the vector that match the given condition and removes them from the vector. More...
 
const CMutexmutex () const
 Returns a reference to the underlying mutex of the CMutexVector. More...
 
const std::vector< T > & rawVector () const
 Returns a reference to the underlying vector. More...
 
auto begin () const
 Returns an iterator to the beginning of the vector. More...
 
auto end () const
 Returns an iterator to the end of the vector. More...
 
auto cbegin () const
 Returns a const iterator to the beginning of the vector. More...
 
auto cend () const
 Returns a const iterator to the end of the vector. More...
 
size_t size () const
 Returns the size of the vector. More...
 
bool isEmpty () const
 Checks if the vector is empty. More...
 
T & first ()
 Returns a reference to the first element in the vector. More...
 
T & last ()
 Returns a reference to the last element in the vector. More...
 
T & at (const size_t i_nIndex)
 Returns a reference to the element at the specified index. More...
 
std::vector< T > toStdVector () const
 Converts the CMutexVector to a standard vector. More...
 
bool contains (const T &i_oValue) const
 Checks if the vector contains the specified value. More...
 
void resize (const size_t i_nSize)
 Resizes the vector to the specified size. More...
 
void reserve (const size_t i_nSize)
 Reserves memory for the specified number of elements. More...
 
void push_back (const T &i_oValue)
 Appends a new element to the end of the vector. More...
 
void push_back (T &&i_oValue)
 Moves a new element to the end of the vector. More...
 
void push_back (const std::vector< T > &i_atValue)
 Appends a vector of elements to the end of the vector. More...
 
void push_back (std::vector< T > &&i_atValue)
 Moves a vector of elements to the end of the vector. More...
 
void push_back (const CMutexVector< T > &i_atValue)
 Appends another CMutexVector to the end of the vector. More...
 
void push_back (CMutexVector< T > &&i_atValue)
 Moves another CMutexVector to the end of the vector. More...
 
bool removeAt (const size_t i_nIndex)
 Removes the element at the specified index from the vector. More...
 
bool remove (const T &i_oValue)
 Removes the first occurrence of the specified value from the vector. More...
 
void clear ()
 Removes all elements from the vector.
 
CMutexVectoroperator= (const std::vector< T > &i_tOther)
 Assignment operator that copies a std::vector<T> to the CMutexVector. More...
 
CMutexVectoroperator= (std::vector< T > &&i_tOther)
 Assignment operator that moves a std::vector<T> to the CMutexVector. More...
 
virtual CMutexVectoroperator= (const CMutexVector< T > &i_tOther)
 Assignment operator that copies another CMutexVector to the CMutexVector. More...
 
virtual CMutexVectoroperator= (CMutexVector< T > &&i_tOther) noexcept
 Assignment operator that moves another CMutexVector to the CMutexVector. More...
 
T & operator[] (const size_t i_nIndex)
 Access operator that returns a reference to the element at the specified index. More...
 
const T & operator[] (const size_t i_nIndex) const
 Const access operator that returns a const reference to the element at the specified index. More...
 

Member Function Documentation

◆ at()

template<typename T >
T& Devel::Threading::CMutexVector< T >::at ( const size_t  i_nIndex)
inline

Returns a reference to the element at the specified index.

Parameters
i_nIndexThe index of the element.
Returns
A reference to the element.

◆ begin()

template<typename T >
auto Devel::Threading::CMutexVector< T >::begin ( ) const
inline

Returns an iterator to the beginning of the vector.

Returns
An iterator to the beginning.

◆ cbegin()

template<typename T >
auto Devel::Threading::CMutexVector< T >::cbegin ( ) const
inline

Returns a const iterator to the beginning of the vector.

Returns
A const iterator to the beginning.

◆ cend()

template<typename T >
auto Devel::Threading::CMutexVector< T >::cend ( ) const
inline

Returns a const iterator to the end of the vector.

Returns
A const iterator to the end.

◆ contains()

template<typename T >
bool Devel::Threading::CMutexVector< T >::contains ( const T &  i_oValue) const
inline

Checks if the vector contains the specified value.

Parameters
i_oValueThe value to check for.
Returns
True if the vector contains the value, false otherwise.

◆ end()

template<typename T >
auto Devel::Threading::CMutexVector< T >::end ( ) const
inline

Returns an iterator to the end of the vector.

Returns
An iterator to the end.

◆ find()

template<typename T >
T Devel::Threading::CMutexVector< T >::find ( FnMatch  i_fnMatch) const
inline

Finds the first element in the vector that matches the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
The first matching element.
Exceptions
NoEntryFoundExceptionif no matching element is found.

◆ findAll()

template<typename T >
std::vector<T> Devel::Threading::CMutexVector< T >::findAll ( FnMatch  i_fnMatch) const
inline

Finds all elements in the vector that match the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
A vector containing all matching elements.

◆ findIndex()

template<typename T >
size_t Devel::Threading::CMutexVector< T >::findIndex ( FnMatch  i_fnMatch) const
inline

Finds the index of the first element in the vector that matches the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
The index of the first matching element.
(~0) if no matching element is found.

◆ findIndexAll()

template<typename T >
std::vector<size_t> Devel::Threading::CMutexVector< T >::findIndexAll ( FnMatch  i_fnMatch) const
inline

Finds all indexes of the elements in the vector that match the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
A vector containing all indexes of the matching elements.

◆ first()

template<typename T >
T& Devel::Threading::CMutexVector< T >::first ( )
inline

Returns a reference to the first element in the vector.

Returns
A reference to the first element.

◆ get()

template<typename T >
T Devel::Threading::CMutexVector< T >::get ( FnMatch  i_fnMatch) const
inline

Alias for find(FnMatch).

Parameters
i_fnMatchThe matching condition.
Returns
The first matching element.
Exceptions
NoEntryFoundExceptionif no matching element is found.

◆ getAll()

template<typename T >
std::vector<T> Devel::Threading::CMutexVector< T >::getAll ( FnMatch  i_fnMatch) const
inline

Alias for findAll(FnMatch).

Parameters
i_fnMatchThe matching condition.
Returns
A vector containing all matching elements.

◆ indexOf()

template<typename T >
size_t Devel::Threading::CMutexVector< T >::indexOf ( FnMatch  i_fnMatch) const
inline

Alias for findIndex(FnMatch).

Parameters
i_fnMatchThe matching condition.
Returns
The index of the first matching element.
(~0) if no matching element is found.

◆ indexOfAll()

template<typename T >
std::vector<size_t> Devel::Threading::CMutexVector< T >::indexOfAll ( FnMatch  i_fnMatch) const
inline

Alias for findIndexAll(FnMatch).

Parameters
i_fnMatchThe matching condition.
Returns
A vector containing all indexes of the matching elements.

◆ isEmpty()

template<typename T >
bool Devel::Threading::CMutexVector< T >::isEmpty ( ) const
inline

Checks if the vector is empty.

Returns
True if the vector is empty, false otherwise.

◆ last()

template<typename T >
T& Devel::Threading::CMutexVector< T >::last ( )
inline

Returns a reference to the last element in the vector.

Returns
A reference to the last element.

◆ mutex()

template<typename T >
const CMutex& Devel::Threading::CMutexVector< T >::mutex ( ) const
inline

Returns a reference to the underlying mutex of the CMutexVector.

Returns
A reference to the mutex.

◆ operator=() [1/4]

template<typename T >
virtual CMutexVector& Devel::Threading::CMutexVector< T >::operator= ( CMutexVector< T > &&  i_tOther)
inlinevirtualnoexcept

Assignment operator that moves another CMutexVector to the CMutexVector.

Parameters
i_tOtherThe CMutexVector to move.
Returns
A reference to the CMutexVector after assignment.

◆ operator=() [2/4]

template<typename T >
virtual CMutexVector& Devel::Threading::CMutexVector< T >::operator= ( const CMutexVector< T > &  i_tOther)
inlinevirtual

Assignment operator that copies another CMutexVector to the CMutexVector.

Parameters
i_tOtherThe CMutexVector to copy.
Returns
A reference to the CMutexVector after assignment.

◆ operator=() [3/4]

template<typename T >
CMutexVector& Devel::Threading::CMutexVector< T >::operator= ( const std::vector< T > &  i_tOther)
inline

Assignment operator that copies a std::vector<T> to the CMutexVector.

Parameters
i_tOtherThe std::vector<T> to copy.
Returns
A reference to the CMutexVector after assignment.

◆ operator=() [4/4]

template<typename T >
CMutexVector& Devel::Threading::CMutexVector< T >::operator= ( std::vector< T > &&  i_tOther)
inline

Assignment operator that moves a std::vector<T> to the CMutexVector.

Parameters
i_tOtherThe std::vector<T> to move.
Returns
A reference to the CMutexVector after assignment.

◆ operator[]() [1/2]

template<typename T >
T& Devel::Threading::CMutexVector< T >::operator[] ( const size_t  i_nIndex)
inline

Access operator that returns a reference to the element at the specified index.

Parameters
i_nIndexThe index of the element.
Returns
A reference to the element.

◆ operator[]() [2/2]

template<typename T >
const T& Devel::Threading::CMutexVector< T >::operator[] ( const size_t  i_nIndex) const
inline

Const access operator that returns a const reference to the element at the specified index.

Parameters
i_nIndexThe index of the element.
Returns
A const reference to the element.

◆ push_back() [1/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( CMutexVector< T > &&  i_atValue)
inline

Moves another CMutexVector to the end of the vector.

Parameters
i_atValueThe CMutexVector to move.

◆ push_back() [2/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( const CMutexVector< T > &  i_atValue)
inline

Appends another CMutexVector to the end of the vector.

Parameters
i_atValueThe CMutexVector to append.

◆ push_back() [3/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( const std::vector< T > &  i_atValue)
inline

Appends a vector of elements to the end of the vector.

Parameters
i_atValueThe vector of elements to append.

◆ push_back() [4/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( const T &  i_oValue)
inline

Appends a new element to the end of the vector.

Parameters
i_oValueThe value to append.

◆ push_back() [5/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( std::vector< T > &&  i_atValue)
inline

Moves a vector of elements to the end of the vector.

Parameters
i_atValueThe vector of elements to move.

◆ push_back() [6/6]

template<typename T >
void Devel::Threading::CMutexVector< T >::push_back ( T &&  i_oValue)
inline

Moves a new element to the end of the vector.

Parameters
i_oValueThe value to move.

◆ rawVector()

template<typename T >
const std::vector<T>& Devel::Threading::CMutexVector< T >::rawVector ( ) const
inline

Returns a reference to the underlying vector.

Returns
A reference to the vector.

◆ remove() [1/2]

template<typename T >
bool Devel::Threading::CMutexVector< T >::remove ( const T &  i_oValue)
inline

Removes the first occurrence of the specified value from the vector.

Parameters
i_oValueThe value to remove.
Returns
True if the value was removed, false otherwise.

◆ remove() [2/2]

template<typename T >
bool Devel::Threading::CMutexVector< T >::remove ( FnMatch  i_fnMatch)
inline

Removes the first element from the vector that matches the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
True if an element was removed, false otherwise.

◆ removeAll()

template<typename T >
bool Devel::Threading::CMutexVector< T >::removeAll ( FnMatch  i_fnMatch)
inline

Removes all elements from the vector that match the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
True if any elements were removed, false otherwise.

◆ removeAt()

template<typename T >
bool Devel::Threading::CMutexVector< T >::removeAt ( const size_t  i_nIndex)
inline

Removes the element at the specified index from the vector.

Parameters
i_nIndexThe index of the element to remove.
Returns
True if the element was removed, false otherwise.

◆ removeOne()

template<typename T >
bool Devel::Threading::CMutexVector< T >::removeOne ( FnMatch  i_fnMatch)
inline

Removes the first element from the vector that matches the given condition.

Parameters
i_fnMatchThe matching condition.
Returns
True if an element was removed, false otherwise.

◆ reserve()

template<typename T >
void Devel::Threading::CMutexVector< T >::reserve ( const size_t  i_nSize)
inline

Reserves memory for the specified number of elements.

Parameters
i_nSizeThe number of elements to reserve memory for.

◆ resize()

template<typename T >
void Devel::Threading::CMutexVector< T >::resize ( const size_t  i_nSize)
inline

Resizes the vector to the specified size.

Parameters
i_nSizeThe new size of the vector.

◆ size()

template<typename T >
size_t Devel::Threading::CMutexVector< T >::size ( ) const
inline

Returns the size of the vector.

Returns
The size of the vector.

◆ take()

template<typename T >
T Devel::Threading::CMutexVector< T >::take ( FnMatch  i_fnMatch) const
inline

Takes the first element from the vector that matches the given condition and removes it from the vector.

Parameters
i_fnMatchThe matching condition.
Returns
The first matching element.
Exceptions
NoEntryFoundExceptionif no matching element is found.

◆ takeAll()

template<typename T >
std::vector<T> Devel::Threading::CMutexVector< T >::takeAll ( FnMatch  i_fnMatch) const
inline

Takes all elements from the vector that match the given condition and removes them from the vector.

Parameters
i_fnMatchThe matching condition.
Returns
A vector containing all matching elements.

◆ toStdVector()

template<typename T >
std::vector<T> Devel::Threading::CMutexVector< T >::toStdVector ( ) const
inline

Converts the CMutexVector to a standard vector.

Returns
A std::vector<T> containing the elements of the CMutexVector.

The documentation for this class was generated from the following file: