AGXDynamics  2.31.1.0
agxData::Vector< T > Class Template Reference

#include <Vector.h>

+ Inheritance diagram for agxData::Vector< T >:

Public Types

typedef const T * const_iterator
 
typedef const T * const_pointer
 
typedef const T & const_reference
 
typedef ptrdiff_t difference_type
 
typedef T * iterator
 
typedef std::random_access_iterator_tag iterator_category
 
typedef T * pointer
 
typedef T & reference
 
typedef size_t size_type
 
typedef T Type
 
typedef T value_type
 

Public Member Functions

 Vector ()
 
 Vector (agxData::Buffer *buffer)
 
 ~Vector ()
 
void _setBuffer (agxData::Buffer *buffer)
 Set the buffer while maintaining the current range, should normally not be used. More...
 
agx::GlobalResult::Transaction allocateResult (size_t numElements)
 
const AbstractArray & asArray () const
 
AbstractArray & asArray ()
 
template<typename T >
Array< T > & asArray ()
 
template<typename T >
const Array< T > & asArray () const
 
const AbstractScalar & asScalar () const
 
AbstractScalar & asScalar ()
 
template<typename T >
Scalar< T > & asScalar ()
 
template<typename T >
const Scalar< T > & asScalar () const
 
T & at (size_t index)
 
const T & at (size_t index) const
 
T & back ()
 
const T & back () const
 
iterator begin ()
 
const_iterator begin () const
 
const agxData::Buffer * buffer () const
 
agxData::Buffer * buffer ()
 
void clear ()
 Remove all elements, optionally with maintained buffer allocation. More...
 
void commit ()
 Commit all changes. More...
 
size_t commitResult (size_t numElements, const void *localResult, agx::Index sortIndex)
 
size_t commitResult (size_t numElements, const void *localResult)
 
template<typename T2 >
size_t commitResult (const T2 &vector, agx::Index sortIndex)
 
template<typename T2 >
size_t commitResult (const T2 &vector)
 
template<typename T2 >
bool contains (const T2 &element) const
 
void decrement (size_t numElements=1)
 
bool empty () const
 
iterator end ()
 
const_iterator end () const
 
iterator erase (iterator position)
 STL erase functionality. More...
 
iterator erase (iterator start, iterator end)
 
void erase (size_t index)
 Erase elements using indices instead of iterators. More...
 
void erase (size_t start, size_t end)
 
iterator eraseFast (const_iterator position)
 Fast erase, replacing the erased element with the last element. More...
 
void eraseFast (size_t index)
 
template<typename T2 >
size_t find (const T2 &element) const
 The index of the first occurrence of an element that is equal to the given element. More...
 
template<typename T2 >
bool findAndErase (const T2 &element, bool searchMultiple=false)
 Find and erase an element. More...
 
T & front ()
 
const T & front () const
 
agxData::Format * getFormat ()
 
const agxData::Format * getFormat () const
 
agx::GlobalResult * getGlobalResult ()
 
T * increment (size_t numElements=1, const T &value=T())
 Resize using a increment. More...
 
void init (agxData::Buffer *buffer, agx::IndexRange32 range)
 Set the buffer that the array will access, as well as the range of the buffer that is to be covered. More...
 
void init (agxData::Buffer *buffer)
 Set the buffer that the array will access. The range is set to the entire buffer. More...
 
void init ()
 Set to empty array. More...
 
iterator insert (iterator position, const T &value)
 
void insert (size_t index, const T &value)
 
template<typename InputIterator >
void insert (iterator it, InputIterator first, InputIterator last)
 
bool isValid () const
 
T & operator[] (size_t index)
 
const T & operator[] (size_t index) const
 
agxData::Array< T > operator[] (agx::IndexRange32 subRange) const
 
void pop_back ()
 Remove the back element. More...
 
T * ptr ()
 
const T * ptr () const
 
template<typename T2 >
void push_back (const T2 &value)
 Append a new data element to the vector. More...
 
agx::IndexRange32 & range ()
 
const agx::IndexRange32 & range () const
 
void reserve (size_t size)
 Reserve capacity in the vector. More...
 
void resize (size_t size, const T &value=T())
 Resize the vector, which then enables direct addressing using the bracket '[]' operator. More...
 
void setRange (size_t startIndex, size_t endIndex)
 Set the range of the buffer that the array will cover. More...
 
void setRange (agx::IndexRange32 range)
 Set the range of the buffer that the array will cover. More...
 
size_t size () const
 
agxData::Array< T > slice (agx::IndexRange32 subRange) const
 
void sync ()
 Updates the internal data access pointer. Called when the back end buffer is reallocated. More...
 

Static Public Member Functions

static agxData::Array< T > raw (T *buffer, agx::Index size)
 Array creation helper method that creates an array covering the given memory area. More...
 
static const agxData::Array< T > raw (const T *buffer, agx::Index size)
 

Static Public Attributes

static const bool IsScalar = false
 

Protected Attributes

agxData::Buffer * m_buffer
 
void * m_ptr
 
agx::IndexRange32 m_range
 

Detailed Description

template<typename T>
class agxData::Vector< T >

Definition at line 27 of file ata/Vector.h.

Member Typedef Documentation

◆ const_iterator

template<typename T >
typedef const T* agxData::Vector< T >::const_iterator

Definition at line 38 of file ata/Vector.h.

◆ const_pointer

template<typename T >
typedef const T* agxData::Vector< T >::const_pointer

Definition at line 33 of file ata/Vector.h.

◆ const_reference

template<typename T >
typedef const T& agxData::Vector< T >::const_reference

Definition at line 35 of file ata/Vector.h.

◆ difference_type

template<typename T >
typedef ptrdiff_t agxData::Vector< T >::difference_type

Definition at line 40 of file ata/Vector.h.

◆ iterator

template<typename T >
typedef T* agxData::Vector< T >::iterator

Definition at line 37 of file ata/Vector.h.

◆ iterator_category

template<typename T >
typedef std::random_access_iterator_tag agxData::Vector< T >::iterator_category

Definition at line 39 of file ata/Vector.h.

◆ pointer

template<typename T >
typedef T* agxData::Vector< T >::pointer

Definition at line 32 of file ata/Vector.h.

◆ reference

template<typename T >
typedef T& agxData::Vector< T >::reference

Definition at line 34 of file ata/Vector.h.

◆ size_type

template<typename T >
typedef size_t agxData::Vector< T >::size_type

Definition at line 36 of file ata/Vector.h.

◆ Type

template<typename T >
typedef T agxData::Vector< T >::Type

Definition at line 30 of file ata/Vector.h.

◆ value_type

template<typename T >
typedef T agxData::Vector< T >::value_type

Definition at line 31 of file ata/Vector.h.

Constructor & Destructor Documentation

◆ Vector() [1/2]

template<typename T >
agxData::Vector< T >::Vector ( )
explicit

Definition at line 130 of file ata/Vector.h.

◆ Vector() [2/2]

template<typename T >
agxData::Vector< T >::Vector ( agxData::Buffer *  buffer)
explicit

Definition at line 135 of file ata/Vector.h.

References agxVerify, and agxData::Buffer::getStorage().

◆ ~Vector()

template<typename T >
agxData::Vector< T >::~Vector ( )

Definition at line 141 of file ata/Vector.h.

References agxData::Vector< T >::commit().

Member Function Documentation

◆ _setBuffer()

void agxData::AbstractArray::_setBuffer ( agxData::Buffer *  buffer)
inherited

Set the buffer while maintaining the current range, should normally not be used.

Definition at line 679 of file Buffer.h.

References agxAssert, agxData::AbstractArray::buffer(), agxData::AbstractArray::m_buffer, and agxData::AbstractArray::sync().

◆ allocateResult()

template<typename T >
agx::GlobalResult::Transaction agxData::Array< T >::allocateResult ( size_t  numElements)
inherited

◆ asArray() [1/4]

const AbstractArray & agxData::Data::asArray ( ) const
inherited

Definition at line 617 of file Buffer.h.

◆ asArray() [2/4]

AbstractArray & agxData::Data::asArray ( )
inherited

Definition at line 616 of file Buffer.h.

◆ asArray() [3/4]

template<typename T >
Array< T > & agxData::Data::asArray ( )
inherited

Definition at line 620 of file Buffer.h.

◆ asArray() [4/4]

template<typename T >
const Array< T > & agxData::Data::asArray ( ) const
inherited

Definition at line 623 of file Buffer.h.

◆ asScalar() [1/4]

const AbstractScalar & agxData::Data::asScalar ( ) const
inherited

Definition at line 92 of file Scalar.h.

◆ asScalar() [2/4]

AbstractScalar & agxData::Data::asScalar ( )
inherited

Definition at line 91 of file Scalar.h.

◆ asScalar() [3/4]

template<typename T >
Scalar< T > & agxData::Data::asScalar ( )
inherited

Definition at line 95 of file Scalar.h.

◆ asScalar() [4/4]

template<typename T >
const Scalar< T > & agxData::Data::asScalar ( ) const
inherited

Definition at line 98 of file Scalar.h.

◆ at() [1/2]

template<typename T >
T & agxData::Array< T >::at ( size_t  index)
inherited
Returns
A reference to the element at the given index in the array.

Definition at line 860 of file Buffer.h.

◆ at() [2/2]

template<typename T >
const T & agxData::Array< T >::at ( size_t  index) const
inherited

Definition at line 868 of file Buffer.h.

◆ back() [1/2]

template<typename T >
T & agxData::Array< T >::back ( )
inherited
Returns
A reference to the last element of the array.

Definition at line 820 of file Buffer.h.

Referenced by agx::createCell(), agxData::Vector< T >::pop_back(), and agxData::Vector< T >::push_back().

◆ back() [2/2]

template<typename T >
const T & agxData::Array< T >::back ( ) const
inherited

Definition at line 812 of file Buffer.h.

◆ begin() [1/2]

template<typename T >
Array< T >::iterator agxData::Array< T >::begin ( )
inherited
Returns
An iterator to the first element of the array.

Definition at line 888 of file Buffer.h.

Referenced by agxData::Vector< T >::erase(), agxData::Vector< T >::eraseFast(), and agxData::Vector< T >::insert().

◆ begin() [2/2]

template<typename T >
Array< T >::const_iterator agxData::Array< T >::begin ( ) const
inherited

Definition at line 891 of file Buffer.h.

◆ buffer() [1/2]

◆ buffer() [2/2]

Buffer * agxData::AbstractArray::buffer ( )
inherited

Definition at line 719 of file Buffer.h.

References agxData::AbstractArray::m_buffer.

◆ clear()

template<typename T >
void agxData::Vector< T >::clear ( )

Remove all elements, optionally with maintained buffer allocation.

Definition at line 331 of file ata/Vector.h.

References agxAssert, agxData::AbstractArray::buffer(), agxData::Vector< T >::decrement(), and m_size.

◆ commit()

◆ commitResult() [1/4]

template<typename T >
size_t agxData::Array< T >::commitResult ( size_t  numElements,
const void *  localResult,
agx::Index  sortIndex 
)
inherited
See also
agx::GlobalResult::commitResult

Definition at line 578 of file Buffer.h.

◆ commitResult() [2/4]

template<typename T >
size_t agxData::Array< T >::commitResult ( size_t  numElements,
const void *  localResult 
)
inherited

Definition at line 587 of file Buffer.h.

◆ commitResult() [3/4]

template<typename T >
template<typename T2 >
size_t agxData::Array< T >::commitResult ( const T2 &  vector,
agx::Index  sortIndex 
)
inherited
See also
agx::GlobalResult::commitResult

Definition at line 596 of file Buffer.h.

◆ commitResult() [4/4]

template<typename T >
template<typename T2 >
size_t agxData::Array< T >::commitResult ( const T2 &  vector)
inherited

Definition at line 606 of file Buffer.h.

◆ contains()

template<typename T >
template<typename T2 >
bool agxData::Array< T >::contains ( const T2 &  element) const
inherited
Returns
True if the array contains at least one element that is equal to the given element.

Definition at line 920 of file Buffer.h.

◆ decrement()

◆ empty()

bool agxData::AbstractArray::empty ( ) const
inherited
Returns
True if size is zero.

Definition at line 713 of file Buffer.h.

References agxData::AbstractArray::m_range, and agx::IndexRangeT< T >::size().

Referenced by agx::createCell(), and agxData::Vector< T >::pop_back().

◆ end() [1/2]

template<typename T >
Array< T >::iterator agxData::Array< T >::end ( )
inherited
Returns
An iterator to one past the last element of the array.

Definition at line 894 of file Buffer.h.

◆ end() [2/2]

template<typename T >
Array< T >::const_iterator agxData::Array< T >::end ( ) const
inherited

Definition at line 897 of file Buffer.h.

◆ erase() [1/4]

template<typename T >
Vector< T >::iterator agxData::Vector< T >::erase ( iterator  position)

◆ erase() [2/4]

template<typename T >
Vector< T >::iterator agxData::Vector< T >::erase ( iterator  start,
iterator  end 
)

◆ erase() [3/4]

template<typename T >
void agxData::Vector< T >::erase ( size_t  index)

Erase elements using indices instead of iterators.

Definition at line 277 of file ata/Vector.h.

References agxAssert, agxData::AbstractArray::buffer(), agxData::Buffer::m_size, and agxData::Array< T >::ptr().

◆ erase() [4/4]

template<typename T >
void agxData::Vector< T >::erase ( size_t  start,
size_t  end 
)

◆ eraseFast() [1/2]

template<typename T >
Vector< T >::iterator agxData::Vector< T >::eraseFast ( const_iterator  position)

Fast erase, replacing the erased element with the last element.

Definition at line 310 of file ata/Vector.h.

References agxAssert, agxData::Array< T >::begin(), and agxData::AbstractArray::buffer().

◆ eraseFast() [2/2]

template<typename T >
void agxData::Vector< T >::eraseFast ( size_t  index)

◆ find()

template<typename T >
template<typename T2 >
size_t agxData::Array< T >::find ( const T2 &  element) const
inherited

The index of the first occurrence of an element that is equal to the given element.

If there is no such element, then InvalidIndex is returned.

Parameters
elementThe value to search for.
Returns
Index of the first match, or if there is no match InvalidIndex.

Definition at line 908 of file Buffer.h.

◆ findAndErase()

template<typename T >
template<typename T2 >
bool agxData::Vector< T >::findAndErase ( const T2 &  element,
bool  searchMultiple = false 
)

Find and erase an element.

Parameters
elementThe element to search for
searchMultipleSet to true if search should continue after element is found, otherwise the search terminates on first match.
Returns
true if the element was found, else false

Definition at line 338 of file ata/Vector.h.

References agxAssert, agxData::AbstractArray::buffer(), agxData::Vector< T >::erase(), agxData::Buffer::m_size, and agxData::Array< T >::ptr().

◆ front() [1/2]

template<typename T >
T & agxData::Array< T >::front ( )
inherited
Returns
A reference to the first element of the array.

Definition at line 836 of file Buffer.h.

◆ front() [2/2]

template<typename T >
const T & agxData::Array< T >::front ( ) const
inherited

Definition at line 828 of file Buffer.h.

◆ getFormat() [1/2]

Format * agxData::AbstractArray::getFormat ( )
inherited
Returns
The format of the covered Buffer. Will return nullptr if the array is invalid.

Definition at line 726 of file Buffer.h.

References agxData::Buffer::getFormat(), and agxData::AbstractArray::m_buffer.

◆ getFormat() [2/2]

const Format * agxData::AbstractArray::getFormat ( ) const
inherited

Definition at line 727 of file Buffer.h.

References agxData::Buffer::getFormat(), and agxData::AbstractArray::m_buffer.

◆ getGlobalResult()

template<typename T >
agx::GlobalResult * agxData::Array< T >::getGlobalResult ( )
inherited
Returns
The global result object associated with the buffer that the array is bound to.

Definition at line 564 of file Buffer.h.

◆ increment()

template<typename T >
T * agxData::Vector< T >::increment ( size_t  numElements = 1,
const T &  value = T() 
)

◆ init() [1/3]

void agxData::AbstractArray::init ( agxData::Buffer *  buffer,
agx::IndexRange32  range 
)
inherited

◆ init() [2/3]

void agxData::AbstractArray::init ( agxData::Buffer *  buffer)
inherited

Set the buffer that the array will access. The range is set to the entire buffer.

Definition at line 673 of file Buffer.h.

References agxAssert, agxData::AbstractArray::init(), and agxData::Buffer::size().

◆ init() [3/3]

void agxData::AbstractArray::init ( )
inherited

◆ insert() [1/3]

template<typename T >
Vector< T >::iterator agxData::Vector< T >::insert ( iterator  position,
const T &  value 
)

◆ insert() [2/3]

template<typename T >
void agxData::Vector< T >::insert ( size_t  index,
const T &  value 
)

◆ insert() [3/3]

template<typename T >
template<typename InputIterator >
void agxData::Vector< T >::insert ( iterator  it,
InputIterator  first,
InputIterator  last 
)

◆ isValid()

bool agxData::AbstractArray::isValid ( ) const
inherited
Returns
True if the array is valid, i.e., is bound to a back end buffer.

Definition at line 724 of file Buffer.h.

References agxData::AbstractArray::m_buffer.

◆ operator[]() [1/3]

template<typename T >
T & agxData::Array< T >::operator[] ( size_t  index)
inherited
Returns
A reference to the element at the given index in the array.

Definition at line 845 of file Buffer.h.

◆ operator[]() [2/3]

template<typename T >
const T & agxData::Array< T >::operator[] ( size_t  index) const
inherited

Definition at line 854 of file Buffer.h.

◆ operator[]() [3/3]

template<typename T >
Array< T > agxData::Array< T >::operator[] ( agx::IndexRange32  subRange) const
inherited
Returns
Create a new array that covers a subset of the current array.

Definition at line 882 of file Buffer.h.

◆ pop_back()

◆ ptr() [1/2]

template<typename T >
T * agxData::Array< T >::ptr ( )
inherited

◆ ptr() [2/2]

template<typename T >
const T * agxData::Array< T >::ptr ( ) const
inherited

Definition at line 904 of file Buffer.h.

◆ push_back()

template<typename T >
template<typename T2 >
void agxData::Vector< T >::push_back ( const T2 &  value)

◆ range() [1/2]

◆ range() [2/2]

const agx::IndexRange32 & agxData::AbstractArray::range ( ) const
inherited

Definition at line 722 of file Buffer.h.

References agxData::AbstractArray::m_range.

◆ raw() [1/2]

template<typename T>
Array< T > agxData::Array< T >::raw ( T *  buffer,
agx::Index  size 
)
staticinherited

Array creation helper method that creates an array covering the given memory area.

The created array will not have a back end Buffer object and is therefore invalid. The given memory area will be interpreted as an array of elements of type T.

Parameters
bufferMemory area that the array should index into.
sizeThe length, in number of elements, that the array should cover.
Returns
A new array that covers the given memory area.

Definition at line 733 of file Buffer.h.

◆ raw() [2/2]

template<typename T>
const Array< T > agxData::Array< T >::raw ( const T *  buffer,
agx::Index  size 
)
staticinherited

Definition at line 744 of file Buffer.h.

◆ reserve()

template<typename T >
void agxData::Vector< T >::reserve ( size_t  size)

Reserve capacity in the vector.

Definition at line 191 of file ata/Vector.h.

References agxAssert, and agxData::AbstractArray::buffer().

◆ resize()

template<typename T >
void agxData::Vector< T >::resize ( size_t  size,
const T &  value = T() 
)

Resize the vector, which then enables direct addressing using the bracket '[]' operator.

Definition at line 165 of file ata/Vector.h.

References AGX_FORCE_INLINE, AGX_VECTOR_SHRINK_THRESHOLD, agxAssert, agxData::AbstractArray::buffer(), agxData::Vector< T >::increment(), m_capacity, m_size, agx::max(), agxData::Buffer::reserve(), and agxData::AbstractArray::sync().

◆ setRange() [1/2]

void agxData::AbstractArray::setRange ( size_t  startIndex,
size_t  endIndex 
)
inherited

Set the range of the buffer that the array will cover.

Definition at line 696 of file Buffer.h.

◆ setRange() [2/2]

void agxData::AbstractArray::setRange ( agx::IndexRange32  range)
inherited

◆ size()

size_t agxData::AbstractArray::size ( ) const
inherited

◆ slice()

template<typename T >
Array< T > agxData::Array< T >::slice ( agx::IndexRange32  subRange) const
inherited
Returns
Create a new array that covers a subset of the current array.

Definition at line 875 of file Buffer.h.

◆ sync()

Member Data Documentation

◆ IsScalar

template<typename T>
const bool agxData::Array< T >::IsScalar = false
staticinherited

Definition at line 121 of file Array.h.

◆ m_buffer

◆ m_ptr

◆ m_range


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