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

Local scope vector. More...

#include <LocalVector.h>

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

Public Types

enum  ClearPolicy { SHRINK_BUFFER, SHRINK_BUFFER_AVERAGED, MAINTAIN_BUFFER }
 agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control what should become of the container's memory. More...
 
typedef const T * const_iterator
 
typedef const T * const_pointer
 
typedef const T & const_reference
 
typedef std::reverse_iterator< const_iterator > const_reverse_iterator
 
typedef ptrdiff_t difference_type
 
typedef T * iterator
 
typedef T * pointer
 
typedef T & reference
 
typedef std::reverse_iterator< iterator > reverse_iterator
 
typedef size_t size_type
 
typedef T Type
 
typedef T value_type
 

Public Member Functions

 LocalVector ()
 
 LocalVector (size_t size, const T &value=T())
 
 LocalVector (const LocalVector< T > &other)
 
 LocalVector (LocalVector< T > &&other)
 
agx::ThreadLocalAllocator & allocator ()
 
const agx::ThreadLocalAllocator & allocator () const
 
T & at (size_t index) const
 
T & back () const
 
iterator begin ()
 
const_iterator begin () const
 
size_t capacity () const
 Returns the size of the memory are used by the container to store its elements. More...
 
void clear (ClearPolicy policy=SHRINK_BUFFER_AVERAGED)
 Remove all elements, optionally with maintained buffer allocation. More...
 
bool contains (const T2 &element) const
 Test if the vector contains a certain element. More...
 
bool contains (const T &element) const
 
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)
 
size_t find (const T2 &element) const
 Find the index to a matching element, return size() if not found. More...
 
bool findAndErase (const T &element, bool searchMultiple=false)
 Find and erase an element. More...
 
T & front () const
 
T * increment (size_t numElements=1)
 Resize using a increment. More...
 
iterator insert (iterator position, const T &value)
 
void insert (size_t index, const T &value)
 
void insert (const_iterator it, InputIterator first, InputIterator last)
 
void insert (const_iterator it, std::initializer_list< T > ilist)
 
bool operator!= (const VectorPOD< T, agx::ThreadLocalAllocator > &other) const
 
bool operator== (const VectorPOD< T, agx::ThreadLocalAllocator > &other) const
 Compare with other vector, return true if same size and all pairs are equal. More...
 
T & operator[] (size_t i) const
 
void pop_back ()
 
T * ptr ()
 Get access to the internal data buffer. More...
 
const T * ptr () const
 
void push_back (const T &value)
 
void push_back (T &&value)
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
void reserve (size_t size)
 Reserve capacity in the vector. More...
 
void reserveAtLeast (size_t size)
 Reserve capacity in the vector. More...
 
void resize (size_t size)
 Resize the vector, which then enables direct addressing using the bracket '[]' operator. More...
 
void resize (size_t size, const T &value)
 
void shrink_to_fit ()
 Reduce the capacity of the vector to the actual size (number of elements) More...
 
size_t size () const
 
void swap (VectorPOD &other)
 

Protected Attributes

void * m_buffer
 
size_t m_capacity
 
size_t m_size
 

Detailed Description

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

Local scope vector.

Fast allocation/deallocation using a thread local memory buffer.

Should only be used for local, short-lived, frequently created containers.

Beware that a LocalVector's allocation is unstable. All LocalVectors owned by the same thread get their memory allocations from the same memory pool. If the memory pool is exhausted then it is reallocated and ALL LocalVectors owned by that thread get a new buffer. In C++-speak, an operation that invalidates iterators/pointers into one LocalVectors invalidates pointers/iterators to ALL LocalVectors owned by the same thread. Avoid calling functions that may create LocalVectors when holding pointers/interators into LocalVectors, including using range for loops.

Definition at line 43 of file LocalVector.h.

Member Typedef Documentation

◆ const_iterator

typedef const T* agx::VectorPOD< T, agx::ThreadLocalAllocator >::const_iterator
inherited

Definition at line 256 of file Vector.h.

◆ const_pointer

typedef const T* agx::VectorPOD< T, agx::ThreadLocalAllocator >::const_pointer
inherited

Definition at line 251 of file Vector.h.

◆ const_reference

typedef const T& agx::VectorPOD< T, agx::ThreadLocalAllocator >::const_reference
inherited

Definition at line 253 of file Vector.h.

◆ const_reverse_iterator

typedef std::reverse_iterator<const_iterator> agx::VectorPOD< T, agx::ThreadLocalAllocator >::const_reverse_iterator
inherited

Definition at line 323 of file Vector.h.

◆ difference_type

typedef ptrdiff_t agx::VectorPOD< T, agx::ThreadLocalAllocator >::difference_type
inherited

Definition at line 257 of file Vector.h.

◆ iterator

typedef T* agx::VectorPOD< T, agx::ThreadLocalAllocator >::iterator
inherited

Definition at line 255 of file Vector.h.

◆ pointer

typedef T* agx::VectorPOD< T, agx::ThreadLocalAllocator >::pointer
inherited

Definition at line 250 of file Vector.h.

◆ reference

typedef T& agx::VectorPOD< T, agx::ThreadLocalAllocator >::reference
inherited

Definition at line 252 of file Vector.h.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> agx::VectorPOD< T, agx::ThreadLocalAllocator >::reverse_iterator
inherited

Definition at line 322 of file Vector.h.

◆ size_type

typedef size_t agx::VectorPOD< T, agx::ThreadLocalAllocator >::size_type
inherited

Definition at line 254 of file Vector.h.

◆ Type

typedef T agx::VectorPOD< T, agx::ThreadLocalAllocator >::Type
inherited

Definition at line 248 of file Vector.h.

◆ value_type

Definition at line 249 of file Vector.h.

Member Enumeration Documentation

◆ ClearPolicy

agxData::Values from this enumeration is passed to the subclasses' 'clear' method in order to control what should become of the container's memory.

Enumerator
SHRINK_BUFFER 

Buffer is deallocated and replaced by an newly allocated empty buffer.

SHRINK_BUFFER_AVERAGED 

Buffer is shrunk if a smoothing average (which is updated each clear call) goes below a threshold.

MAINTAIN_BUFFER 

Buffer is maintained (normal stl behavior).

Definition at line 42 of file Container.h.

Constructor & Destructor Documentation

◆ LocalVector() [1/4]

template<typename T >
agxData::LocalVector< T >::LocalVector ( )

Definition at line 57 of file LocalVector.h.

◆ LocalVector() [2/4]

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

Definition at line 63 of file LocalVector.h.

◆ LocalVector() [3/4]

template<typename T>
agxData::LocalVector< T >::LocalVector ( const LocalVector< T > &  other)

Definition at line 69 of file LocalVector.h.

◆ LocalVector() [4/4]

template<typename T>
agxData::LocalVector< T >::LocalVector ( LocalVector< T > &&  other)
inline

Definition at line 75 of file LocalVector.h.

Member Function Documentation

◆ allocator() [1/2]

A & agx::VectorPOD< T, A >::allocator ( )
inherited

Definition at line 1593 of file Vector.h.

◆ allocator() [2/2]

const A & agx::VectorPOD< T, A >::allocator ( ) const
inherited

Definition at line 1596 of file Vector.h.

◆ at()

T & agx::VectorPOD< T, A >::at ( size_t  index) const
inherited

Definition at line 1338 of file Vector.h.

◆ back()

T & agx::VectorPOD< T, A >::back ( ) const
inherited

Definition at line 1354 of file Vector.h.

◆ begin() [1/2]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::begin ( )
inherited

Definition at line 1609 of file Vector.h.

◆ begin() [2/2]

VectorPOD< T, A >::const_iterator agx::VectorPOD< T, A >::begin ( ) const
inherited

Definition at line 1615 of file Vector.h.

◆ capacity()

size_t agx::Container::capacity ( ) const
inherited

Returns the size of the memory are used by the container to store its elements.

Some types of containers, e.g. the agx::Vector, will not do a reallocation until the size of the container reaches the capacity. However, this is not the case for e.g., agx::HashTable, which may perform a reallocation earlier.

Returns
The size of the allocated memory area, in number of elements.

Definition at line 135 of file Container.h.

References agx::Container::m_capacity.

Referenced by agx::Vector< WireContactConstraintRef >::operator=().

◆ clear()

void agx::VectorPOD< T, A >::clear ( ClearPolicy  policy = SHRINK_BUFFER_AVERAGED)
inherited

Remove all elements, optionally with maintained buffer allocation.

Definition at line 1149 of file Vector.h.

◆ contains() [1/2]

bool agx::VectorPOD< T, A >::contains ( const T2 &  element) const
inherited

Test if the vector contains a certain element.

Definition at line 1452 of file Vector.h.

◆ contains() [2/2]

bool agx::VectorPOD< T, A >::contains ( const T &  element) const
inherited

Definition at line 1458 of file Vector.h.

◆ empty()

bool agx::Container::empty ( ) const
inherited

◆ end() [1/2]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::end ( )
inherited

Definition at line 1612 of file Vector.h.

◆ end() [2/2]

VectorPOD< T, A >::const_iterator agx::VectorPOD< T, A >::end ( ) const
inherited

Definition at line 1618 of file Vector.h.

◆ erase() [1/4]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::erase ( iterator  position)
inherited

STL erase functionality.

Definition at line 1395 of file Vector.h.

◆ erase() [2/4]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::erase ( iterator  start,
iterator  end 
)
inherited

Definition at line 1403 of file Vector.h.

◆ erase() [3/4]

void agx::VectorPOD< T, A >::erase ( size_t  index)
inherited

Erase elements using indices instead of iterators.

Definition at line 1414 of file Vector.h.

◆ erase() [4/4]

void agx::VectorPOD< T, A >::erase ( size_t  start,
size_t  end 
)
inherited

Definition at line 1420 of file Vector.h.

◆ eraseFast() [1/2]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::eraseFast ( const_iterator  position)
inherited

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

Definition at line 1436 of file Vector.h.

◆ eraseFast() [2/2]

void agx::VectorPOD< T, A >::eraseFast ( size_t  index)
inherited

Definition at line 1444 of file Vector.h.

◆ find()

size_t agx::VectorPOD< T, A >::find ( const T2 &  element) const
inherited

Find the index to a matching element, return size() if not found.

Definition at line 1465 of file Vector.h.

◆ findAndErase()

bool agx::VectorPOD< T, A >::findAndErase ( const T &  element,
bool  searchMultiple = false 
)
inherited

Find and erase an element.

Parameters
element- Element to search for and erase
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 1478 of file Vector.h.

◆ front()

T & agx::VectorPOD< T, A >::front ( ) const
inherited

Definition at line 1346 of file Vector.h.

◆ increment()

T * agx::VectorPOD< T, A >::increment ( size_t  numElements = 1)
inherited

Resize using a increment.

Definition at line 1255 of file Vector.h.

◆ insert() [1/4]

VectorPOD< T, A >::iterator agx::VectorPOD< T, A >::insert ( iterator  position,
const T &  value 
)
inherited

Definition at line 1501 of file Vector.h.

◆ insert() [2/4]

void agx::VectorPOD< T, A >::insert ( size_t  index,
const T &  value 
)
inherited

Definition at line 1539 of file Vector.h.

◆ insert() [3/4]

void agx::VectorPOD< T, A >::insert ( const_iterator  it,
InputIterator  first,
InputIterator  last 
)
inherited

Definition at line 1517 of file Vector.h.

◆ insert() [4/4]

void agx::VectorPOD< T, A >::insert ( const_iterator  it,
std::initializer_list< T >  ilist 
)
inherited

Definition at line 1511 of file Vector.h.

◆ operator!=()

bool agx::VectorPOD< T, A >::operator!= ( const VectorPOD< T, A > &  other) const
inherited

Definition at line 1282 of file Vector.h.

◆ operator==()

bool agx::VectorPOD< T, A >::operator== ( const VectorPOD< T, A > &  other) const
inherited

Compare with other vector, return true if same size and all pairs are equal.

Definition at line 1269 of file Vector.h.

◆ operator[]()

T & agx::VectorPOD< T, A >::operator[] ( size_t  i) const
inherited

Definition at line 1330 of file Vector.h.

◆ pop_back()

void agx::VectorPOD< T, A >::pop_back ( )
inherited

Definition at line 1386 of file Vector.h.

◆ ptr() [1/2]

T * agx::VectorPOD< T, A >::ptr ( )
inherited

Get access to the internal data buffer.

Definition at line 1324 of file Vector.h.

◆ ptr() [2/2]

const T * agx::VectorPOD< T, A >::ptr ( ) const
inherited

Definition at line 1327 of file Vector.h.

◆ push_back() [1/2]

void agx::VectorPOD< T, A >::push_back ( const T &  value)
inherited

Definition at line 1362 of file Vector.h.

◆ push_back() [2/2]

void agx::VectorPOD< T, A >::push_back ( T &&  value)
inherited

Definition at line 1374 of file Vector.h.

◆ rbegin() [1/2]

VectorPOD< T, A >::reverse_iterator agx::VectorPOD< T, A >::rbegin ( )
inherited

Definition at line 1621 of file Vector.h.

◆ rbegin() [2/2]

VectorPOD< T, A >::const_reverse_iterator agx::VectorPOD< T, A >::rbegin ( ) const
inherited

Definition at line 1627 of file Vector.h.

◆ rend() [1/2]

VectorPOD< T, A >::reverse_iterator agx::VectorPOD< T, A >::rend ( )
inherited

Definition at line 1624 of file Vector.h.

◆ rend() [2/2]

VectorPOD< T, A >::const_reverse_iterator agx::VectorPOD< T, A >::rend ( ) const
inherited

Definition at line 1630 of file Vector.h.

◆ reserve()

void agx::VectorPOD< T, A >::reserve ( size_t  size)
inherited

Reserve capacity in the vector.

Definition at line 1235 of file Vector.h.

◆ reserveAtLeast()

void agx::VectorPOD< T, A >::reserveAtLeast ( size_t  size)
inherited

Reserve capacity in the vector.

Let vector grow in same way as push_back() does.

Definition at line 1243 of file Vector.h.

◆ resize() [1/2]

void agx::VectorPOD< T, A >::resize ( size_t  size)
inherited

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

Definition at line 1196 of file Vector.h.

◆ resize() [2/2]

void agx::VectorPOD< T, A >::resize ( size_t  size,
const T &  value 
)
inherited

Definition at line 1216 of file Vector.h.

◆ shrink_to_fit()

void agx::VectorPOD< T, A >::shrink_to_fit ( )
inherited

Reduce the capacity of the vector to the actual size (number of elements)

Definition at line 1186 of file Vector.h.

◆ size()

size_t agx::Container::size ( ) const
inherited
Returns
The number of elements in the container.

Definition at line 134 of file Container.h.

References agx::Container::m_size.

Referenced by agxCollide::GroupFooCollider< ShapeType >::_calculateContacts(), agxData::Array< JacobianElementT >::Array(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::back(), agx::MemoryPoolOld< T >::clear(), agxData::BufferT< T >::commit(), agxSDK::copyVectors(), agx::createMissingTiers(), agxCollide::Space::disableForContacts(), agxSDK::LinkedSegmentIterator< T >::end(), agxSDK::LinkedSegmentIterator< T >::findPrevIndex(), agx::ConstraintImplementation::findSecondaryConstraintGivenType(), agx::MemoryPoolOld< T >::garbageCollect(), agx::ConstraintImplementation::BodyView::getNumBodies(), agx::ConstraintImplementation::SolverBodyView::getPermutedBodyAt(), agxSDK::LinkedSegmentIterator< T >::isEnd(), agxPowerLine::ConnectionIterator< T >::isValid(), agxPowerLine::PhysicalDimensionIterator< UnitPtr >::isValid(), agx::Vector< WireContactConstraintRef >::operator!=(), agx::VectorPOD< agx::Vec6 >::operator!=(), agxSDK::LinkedSegmentIterator< T >::operator+(), agxPowerLine::PhysicalDimensionIterator< UnitPtr >::operator++(), agxSDK::LinkedSegmentIterator< T >::operator-(), agx::Vector< WireContactConstraintRef >::operator=(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::operator=(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::operator=(), agx::VectorPOD< agx::Vec6 >::operator=(), agx::Vector< WireContactConstraintRef >::operator==(), agx::VectorPOD< agx::Vec6 >::operator==(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::operator[](), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::operator[](), agxOSG::RenderStateManager::parseUniform(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::purge(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::purge(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::push_back(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::push_back(), agx::HashSetImplementation< CellPtr, HashFn< CellPtr >, ByteAllocator >::rebuild(), agx::QuadraticProbingHashTableImplementation< SymmetricMaterialPair, agx::ContactMaterialRef, HashFn< SymmetricMaterialPair >, ByteAllocator >::rebuild(), agxRender::HeightFieldProxy::setHeights(), agx::HashVector< agx::UInt32, agx::ref_ptr< RenderProxy > >::size(), agx::SetVector< agx::ref_ptr< agxSDK::EventListener > >::size(), agxVehicle::utils::splitNonconsecutive(), agxWire::transformPointToShape(), agxWire::transformPointToWorld(), agxWire::transformVectorToShape(), agxWire::transformVectorToWorld(), agxModel::triangleIterator(), agx::Event::trigger(), and agxStream::StoreObjects< T >::~StoreObjects().

◆ swap()

void agx::VectorPOD< T, A >::swap ( VectorPOD< T, agx::ThreadLocalAllocator > &  other)
inherited

Definition at line 1660 of file Vector.h.

Member Data Documentation

◆ m_buffer

◆ m_capacity

◆ m_size


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