Loading...
Searching...
No Matches
meshkit::detail::Vector< T > Class Template Reference

std::vector<T> with the QVector-style member names the CDT kernel and plan model use. More...

#include <meshkit/detail/storage.hpp>

Inheritance diagram for meshkit::detail::Vector< T >:
Collaboration diagram for meshkit::detail::Vector< T >:

Public Member Functions

 Vector ()=default
 Empty vector.
 
 Vector (const std::vector< T > &v)
 Copy the elements of a std::vector.
 
 Vector (std::vector< T > &&v)
 Take over the buffer of a std::vector without copying elements.
 
decltype(auto) first ()
 Reference to the first element (front()); the vector must not be empty.
 
decltype(auto) first () const
 Read-only reference to the first element; the vector must not be empty.
 
decltype(auto) last ()
 Reference to the last element (back()); the vector must not be empty.
 
decltype(auto) last () const
 Read-only reference to the last element; the vector must not be empty.
 
const T * constData () const
 Read-only pointer to the contiguous elements (data()).
 
Vector mid (std::ptrdiff_t at, std::ptrdiff_t count=-1) const
 Copy of a contiguous run of elements.
 
void prepend (const T &v)
 Insert a copy of v before the first element; linear in size().
 
void append (const Vector &v)
 Append copies of all elements of v.
 
Vector & operator+= (const Vector &v)
 Append copies of all elements of v; same as append(const Vector &).
 
Vector & operator<< (const T &v)
 Append one element.
 
std::ptrdiff_t size () const noexcept
 Number of elements as a signed std::ptrdiff_t.
 
bool isEmpty () const
 True when the vector holds no elements.
 
void append (const T &v)
 Append a copy of v (push_back).
 
void append (T &&v)
 Append v by move (push_back).
 
T takeLast ()
 Remove the last element and return it by move; the vector must not be empty.
 
T takeFirst ()
 Remove the first element and return it by move; linear in size().
 
void removeLast ()
 Remove the last element (pop_back); the vector must not be empty.
 
void removeAt (int at)
 Erase one element; the elements after it shift down by one.
 
void fill (const T &v)
 Assign v to every existing element; the size is unchanged.
 
void fill (const T &v, std::size_t size)
 Replace the contents with size copies of v (assign()).
 
bool contains (const T &v) const
 Linear search with operator==.
 

Detailed Description

template<class T>
class meshkit::detail::Vector< T >

std::vector<T> with the QVector-style member names the CDT kernel and plan model use.

Lets the same kernel code compile against StandardStorage and against QVector in the Qt storage. Storage, iterator and reference invalidation are those of std::vector, and there is no internal synchronization. size() hides std::vector::size() and returns a signed count. The element helpers (first(), last(), takeFirst(), takeLast(), removeLast(), removeAt()) keep std::vector's preconditions: they do not check for an empty vector or an out-of-range index.

Template Parameters
TElement type.

Constructor & Destructor Documentation

◆ Vector() [1/3]

template<class T>
meshkit::detail::Vector< T >::Vector ( )
default

Empty vector.

Here is the caller graph for this function:

◆ Vector() [2/3]

template<class T>
meshkit::detail::Vector< T >::Vector ( const std::vector< T > & v)
inline

Copy the elements of a std::vector.

Parameters
[in]vSource; copied, not retained.

◆ Vector() [3/3]

template<class T>
meshkit::detail::Vector< T >::Vector ( std::vector< T > && v)
inline

Take over the buffer of a std::vector without copying elements.

Parameters
[in,out]vSource; left empty.

Member Function Documentation

◆ append() [1/3]

template<class T>
void meshkit::detail::Vector< T >::append ( const T & v)
inline

Append a copy of v (push_back).

Parameters
[in]vElement to copy.

◆ append() [2/3]

template<class T>
void meshkit::detail::Vector< T >::append ( const Vector< T > & v)
inline

Append copies of all elements of v.

Parameters
[in]vSource vector; must not be this vector (self-insertion through std::vector::insert is undefined behaviour).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append() [3/3]

template<class T>
void meshkit::detail::Vector< T >::append ( T && v)
inline

Append v by move (push_back).

Parameters
[in,out]vElement to move from.

◆ constData()

template<class T>
const T * meshkit::detail::Vector< T >::constData ( ) const
inline

Read-only pointer to the contiguous elements (data()).

Returns
Pointer invalidated by any reallocation; may be null when the vector is empty.

◆ contains()

template<class T>
bool meshkit::detail::Vector< T >::contains ( const T & v) const
inline

Linear search with operator==.

Parameters
[in]vValue to look for.
Returns
True when some element compares equal to v.

◆ fill() [1/2]

template<class T>
void meshkit::detail::Vector< T >::fill ( const T & v)
inline

Assign v to every existing element; the size is unchanged.

Parameters
[in]vValue to copy.
Here is the caller graph for this function:

◆ fill() [2/2]

template<class T>
void meshkit::detail::Vector< T >::fill ( const T & v,
std::size_t size )
inline

Replace the contents with size copies of v (assign()).

Parameters
[in]vValue to copy; must not refer to an element of this vector.
[in]sizeNew element count.
Here is the call graph for this function:

◆ first() [1/2]

template<class T>
decltype(auto) meshkit::detail::Vector< T >::first ( )
inline

Reference to the first element (front()); the vector must not be empty.

Here is the caller graph for this function:

◆ first() [2/2]

template<class T>
decltype(auto) meshkit::detail::Vector< T >::first ( ) const
inline

Read-only reference to the first element; the vector must not be empty.

◆ isEmpty()

template<class T>
bool meshkit::detail::Vector< T >::isEmpty ( ) const
inline

True when the vector holds no elements.

Here is the caller graph for this function:

◆ last() [1/2]

template<class T>
decltype(auto) meshkit::detail::Vector< T >::last ( )
inline

Reference to the last element (back()); the vector must not be empty.

Here is the caller graph for this function:

◆ last() [2/2]

template<class T>
decltype(auto) meshkit::detail::Vector< T >::last ( ) const
inline

Read-only reference to the last element; the vector must not be empty.

◆ mid()

template<class T>
Vector meshkit::detail::Vector< T >::mid ( std::ptrdiff_t at,
std::ptrdiff_t count = -1 ) const
inline

Copy of a contiguous run of elements.

Parameters
[in]atZero-based start index; must be in [0, size()] (not clamped).
[in]countNumber of elements; negative (the default -1) means up to the end. A run past the end is cut at size().
Returns
New vector holding elements [at, min(size(), at + count)), or [at, size()) when count is negative.
Here is the call graph for this function:

◆ operator+=()

template<class T>
Vector & meshkit::detail::Vector< T >::operator+= ( const Vector< T > & v)
inline

Append copies of all elements of v; same as append(const Vector &).

Parameters
[in]vSource vector; must not be this vector.
Returns
Reference to this vector.
Here is the call graph for this function:

◆ operator<<()

template<class T>
Vector & meshkit::detail::Vector< T >::operator<< ( const T & v)
inline

Append one element.

Parameters
[in]vElement to copy.
Returns
Reference to this vector, for chaining.
Here is the call graph for this function:

◆ prepend()

template<class T>
void meshkit::detail::Vector< T >::prepend ( const T & v)
inline

Insert a copy of v before the first element; linear in size().

Parameters
[in]vElement to copy.

◆ removeAt()

template<class T>
void meshkit::detail::Vector< T >::removeAt ( int at)
inline

Erase one element; the elements after it shift down by one.

Parameters
[in]atZero-based index in [0, size()); not checked.

◆ removeLast()

template<class T>
void meshkit::detail::Vector< T >::removeLast ( )
inline

Remove the last element (pop_back); the vector must not be empty.

Here is the caller graph for this function:

◆ size()

template<class T>
std::ptrdiff_t meshkit::detail::Vector< T >::size ( ) const
inlinenoexcept

Number of elements as a signed std::ptrdiff_t.

Here is the caller graph for this function:

◆ takeFirst()

template<class T>
T meshkit::detail::Vector< T >::takeFirst ( )
inline

Remove the first element and return it by move; linear in size().

The vector must not be empty.

Returns
The former first element.

◆ takeLast()

template<class T>
T meshkit::detail::Vector< T >::takeLast ( )
inline

Remove the last element and return it by move; the vector must not be empty.

Returns
The former last element.
Here is the caller graph for this function:

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