RavEngine
Loading...
Searching...
No Matches
physx::PxArray< T, Alloc > Class Template Reference

#include <PxArray.h>

Inheritance diagram for physx::PxArray< T, Alloc >:
[legend]
Collaboration diagram for physx::PxArray< T, Alloc >:
[legend]

Public Types

typedef T * Iterator
 
typedef const T * ConstIterator
 

Public Member Functions

 PxArray (const PxEMPTY v)
 
PX_INLINE PxArray (const Alloc &alloc=Alloc())
 
PX_INLINE PxArray (uint32_t size, const T &a=T(), const Alloc &alloc=Alloc())
 
template<class A >
PX_INLINE PxArray (const PxArray< T, A > &other, const Alloc &alloc=Alloc())
 
PX_INLINE PxArray (const PxArray &other, const Alloc &alloc=Alloc())
 
PX_INLINE PxArray (const T *first, const T *last, const Alloc &alloc=Alloc())
 
PX_INLINE ~PxArray ()
 
template<class A >
PX_INLINE PxArray & operator= (const PxArray< T, A > &rhs)
 
PX_INLINE PxArray & operator= (const PxArray &t)
 
PX_FORCE_INLINE const T & operator[] (uint32_t i) const
 
PX_FORCE_INLINE T & operator[] (uint32_t i)
 
PX_FORCE_INLINE ConstIterator begin () const
 
PX_FORCE_INLINE Iterator begin ()
 
PX_FORCE_INLINE ConstIterator end () const
 
PX_FORCE_INLINE Iterator end ()
 
PX_FORCE_INLINE const T & front () const
 
PX_FORCE_INLINE T & front ()
 
PX_FORCE_INLINE const T & back () const
 
PX_FORCE_INLINE T & back ()
 
PX_FORCE_INLINE uint32_t size () const
 
PX_INLINE void clear ()
 
PX_FORCE_INLINE bool empty () const
 
PX_INLINE Iterator find (const T &a)
 
PX_INLINE ConstIterator find (const T &a) const
 
PX_FORCE_INLINE T & pushBack (const T &a)
 
PX_INLINE T popBack ()
 
PX_INLINE T & insert ()
 
PX_INLINE void replaceWithLast (uint32_t i)
 
PX_INLINE void replaceWithLast (Iterator i)
 
PX_INLINE bool findAndReplaceWithLast (const T &a)
 
PX_INLINE void remove (uint32_t i)
 
PX_INLINE void removeRange (uint32_t begin, uint32_t count)
 
PX_NOINLINE void resize (const uint32_t size, const T &a=T())
 
PX_NOINLINE void resizeUninitialized (const uint32_t size)
 
PX_INLINE void shrink ()
 
PX_INLINE void reset ()
 
PX_INLINE void resetOrClear ()
 
PX_INLINE void reserve (const uint32_t capacity)
 
PX_FORCE_INLINE uint32_t capacity () const
 
PX_FORCE_INLINE void forceSize_Unsafe (uint32_t size)
 
PX_INLINE void swap (PxArray< T, Alloc > &other)
 
PX_INLINE void assign (const T *first, const T *last)
 
PX_FORCE_INLINE uint32_t isInUserMemory () const
 
PX_INLINE Alloc & getAllocator ()
 return reference to allocator
 

Protected Member Functions

 PxArray (T *memory, uint32_t size, uint32_t capacity, const Alloc &alloc=Alloc())
 
template<class A >
PX_NOINLINE void copy (const PxArray< T, A > &other)
 
PX_INLINE T * allocate (uint32_t size)
 
PX_INLINE void deallocate (void *mem)
 
PX_NOINLINE T & growAndPushBack (const T &a)
 
PX_INLINE void grow (uint32_t capacity)
 
PX_NOINLINE void recreate (uint32_t capacity)
 
PX_INLINE uint32_t capacityIncrement () const
 

Static Protected Member Functions

static PX_INLINE void create (T *first, T *last, const T &a)
 
static PX_INLINE void copy (T *first, T *last, const T *src)
 
static PX_INLINE void destroy (T *first, T *last)
 

Protected Attributes

T * mData
 
uint32_t mSize
 
uint32_t mCapacity
 

Detailed Description

template<class T, class Alloc = typename PxAllocatorTraits<T>::Type>
class physx::PxArray< T, Alloc >

An array is a sequential container.

Implementation note entries between 0 and size are valid objects we use inheritance to build this because the array is included inline in a lot of objects and we want the allocator to take no space if it's not stateful, which aggregation doesn't allow. Also, we want the metadata at the front for the inline case where the allocator contains some inline storage space

Constructor & Destructor Documentation

◆ PxArray() [1/4]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE physx::PxArray< T, Alloc >::PxArray ( const Alloc &  alloc = Alloc())
inlineexplicit

Default array constructor. Initialize an empty array

◆ PxArray() [2/4]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE physx::PxArray< T, Alloc >::PxArray ( uint32_t  size,
const T &  a = T(),
const Alloc &  alloc = Alloc() 
)
inlineexplicit

Initialize array with given capacity

◆ PxArray() [3/4]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
template<class A >
PX_INLINE physx::PxArray< T, Alloc >::PxArray ( const PxArray< T, A > &  other,
const Alloc &  alloc = Alloc() 
)
inlineexplicit

Copy-constructor. Copy all entries from other array

◆ PxArray() [4/4]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE physx::PxArray< T, Alloc >::PxArray ( const T *  first,
const T *  last,
const Alloc &  alloc = Alloc() 
)
inlineexplicit

Initialize array with given length

◆ ~PxArray()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE physx::PxArray< T, Alloc >::~PxArray ( )
inline

Destructor

Member Function Documentation

◆ assign()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::assign ( const T *  first,
const T *  last 
)
inline

Assign a range of values to this vector (resizes to length of range)

◆ back()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE const T & physx::PxArray< T, Alloc >::back ( ) const
inline

Returns a reference to the last element of the array. Undefined if the array is empty

Returns
a reference to the last element of the array

◆ begin()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE ConstIterator physx::PxArray< T, Alloc >::begin ( ) const
inline

Returns a pointer to the initial element of the array.

Returns
a pointer to the initial element of the array.

◆ capacity()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE uint32_t physx::PxArray< T, Alloc >::capacity ( ) const
inline

Query the capacity(allocated mem) for the array.

◆ clear()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::clear ( )
inline

Clears the array.

◆ empty()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE bool physx::PxArray< T, Alloc >::empty ( ) const
inline

Returns whether the array is empty (i.e. whether its size is 0).

Returns
true if the array is empty

◆ end()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE ConstIterator physx::PxArray< T, Alloc >::end ( ) const
inline

Returns an iterator beyond the last element of the array. Do not dereference.

Returns
a pointer to the element beyond the last element of the array.

◆ find()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE Iterator physx::PxArray< T, Alloc >::find ( const T &  a)
inline

Finds the first occurrence of an element in the array.

Parameters
aThe element to find.

◆ findAndReplaceWithLast()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE bool physx::PxArray< T, Alloc >::findAndReplaceWithLast ( const T &  a)
inline

Replaces the first occurrence of the element a with the last element Operation is O(n)

Parameters
aThe position of the element that will be subtracted from this array.
Returns
true if the element has been removed.

◆ forceSize_Unsafe()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE void physx::PxArray< T, Alloc >::forceSize_Unsafe ( uint32_t  size)
inline

Unsafe function to force the size of the array

◆ front()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE const T & physx::PxArray< T, Alloc >::front ( ) const
inline

Returns a reference to the first element of the array. Undefined if the array is empty.

Returns
a reference to the first element of the array

◆ grow()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::grow ( uint32_t  capacity)
inlineprotected

Resizes the available memory for the array.

Parameters
capacityThe number of entries that the set should be able to hold.

◆ growAndPushBack()

template<class T , class Alloc >
PX_NOINLINE T & physx::PxArray< T, Alloc >::growAndPushBack ( const T &  a)
protected

Called when pushBack() needs to grow the array.

Parameters
aThe element that will be added to this array.

◆ insert()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE T & physx::PxArray< T, Alloc >::insert ( )
inline

Construct one element at the end of the array. Operation is O(1).

◆ operator=()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
template<class A >
PX_INLINE PxArray & physx::PxArray< T, Alloc >::operator= ( const PxArray< T, A > &  rhs)
inline

Assignment operator. Copy content (deep-copy)

◆ operator[]() [1/2]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE T & physx::PxArray< T, Alloc >::operator[] ( uint32_t  i)
inline

Array indexing operator.

Parameters
iThe index of the element that will be returned.
Returns
The element i in the array.

◆ operator[]() [2/2]

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE const T & physx::PxArray< T, Alloc >::operator[] ( uint32_t  i) const
inline

Array indexing operator.

Parameters
iThe index of the element that will be returned.
Returns
The element i in the array.

◆ popBack()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE T physx::PxArray< T, Alloc >::popBack ( )
inline

Returns the element at the end of the array. Only legal if the array is non-empty.

◆ pushBack()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE T & physx::PxArray< T, Alloc >::pushBack ( const T &  a)
inline

Adds one element to the end of the array. Operation is O(1).

Parameters
aThe element that will be added to this array.

◆ recreate()

template<class T , class Alloc >
PX_NOINLINE void physx::PxArray< T, Alloc >::recreate ( uint32_t  capacity)
protected

Creates a new memory block, copies all entries to the new block and destroys old entries.

Parameters
capacityThe number of entries that the set should be able to hold.

◆ remove()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::remove ( uint32_t  i)
inline

Subtracts the element on position i from the array. Shift the entire array one step. Operation is O(n)

Parameters
iThe position of the element that will be subtracted from this array.

◆ removeRange()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::removeRange ( uint32_t  begin,
uint32_t  count 
)
inline

Removes a range from the array. Shifts the array so order is maintained. Operation is O(n)

Parameters
beginThe starting position of the element that will be subtracted from this array.
countThe number of elments that will be subtracted from this array.

◆ replaceWithLast()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::replaceWithLast ( uint32_t  i)
inline

Subtracts the element on position i from the array and replace it with the last element. Operation is O(1)

Parameters
iThe position of the element that will be subtracted from this array.

◆ reserve()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::reserve ( const uint32_t  capacity)
inline

Ensure that the array has at least size capacity.

◆ reset()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::reset ( )
inline

Deletes all array elements and frees memory.

◆ resetOrClear()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::resetOrClear ( )
inline

Resets or clears the array depending on occupancy.

◆ resize()

template<class T , class Alloc >
PX_NOINLINE void physx::PxArray< T, Alloc >::resize ( const uint32_t  size,
const T &  a = T() 
)

Resize array

◆ shrink()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::shrink ( )
inline

Resize array such that only as much memory is allocated to hold the existing elements

◆ size()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_FORCE_INLINE uint32_t physx::PxArray< T, Alloc >::size ( ) const
inline

Returns the number of entries in the array. This can, and probably will, differ from the array capacity.

Returns
The number of of entries in the array.

◆ swap()

template<class T , class Alloc = typename PxAllocatorTraits<T>::Type>
PX_INLINE void physx::PxArray< T, Alloc >::swap ( PxArray< T, Alloc > &  other)
inline

Swap contents of an array without allocating temporary storage


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