PxInlineArray#

Defined in include/foundation/PxInlineArray.h

template<typename T, uint32_t N, typename Alloc = typename PxAllocatorTraits<T>::Type>
class PxInlineArray : public PxArray<T, PxInlineAllocator<N * sizeof(T), typename PxAllocatorTraits<T>::Type>>#

Public Types

typedef T *Iterator#
typedef const T *ConstIterator#

Public Functions

inline PxInlineArray(const PxEMPTY v)#
inline bool isInlined() const#
inline void setExtraSize(PxU8 extraSize)#
inline explicit PxInlineArray(const Alloc &alloc = Alloc())#
inline const T &operator[](uint32_t i) const#

Array indexing operator.

Parameters:

i – The index of the element that will be returned.

Returns:

The element i in the array.

inline T &operator[](uint32_t i)#

Array indexing operator.

Parameters:

i – The index of the element that will be returned.

Returns:

The element i in the array.

inline ConstIterator begin() const#

Returns a pointer to the first element of the array.

Returns:

Pointer to the first element of the array.

inline Iterator begin()#
inline ConstIterator end() const#

Returns a pointer beyond the last element of the array. Do not dereference.

Returns:

Pointer to the element beyond the last element of the array.

inline Iterator end()#
inline const T &front() const#

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

Returns:

Reference to the first element of the array

inline T &front()#
inline const T &back() const#

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

Returns:

Reference to the last element of the array

inline T &back()#
inline uint32_t size() const#

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

Returns:

The number of entries in the array.

inline void clear()#

Clears the array. Calls destructor on all elements.

inline bool empty() const#

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

Returns:

True if the array is empty

inline Iterator find(const T &a)#

Finds the first occurrence of an element in the array.

Parameters:

a – The element to find.

Returns:

Pointer to the found element or end() if not found

inline ConstIterator find(const T &a) const#
inline T *pushBack(const T &a)#

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

Parameters:

a – The element that will be added to this array.

Returns:

Pointer to the element that has been added, NULL if operation failed.

inline T popBack()#

Removes and returns the element at the end of the array. Only legal if the array is non-empty.

Returns:

The last element of the array

inline T *insert()#

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

Returns:

Pointer to the element that has been inserted, NULL if operation failed.

inline void replaceWithLast(uint32_t i)#

Removes the element at position i from the array and replaces it with the last element. Operation is O(1)

Parameters:

i – The position of the element that will be removed from this array.

inline void replaceWithLast(Iterator i)#
inline bool findAndReplaceWithLast(const T &a)#

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

Parameters:

a – The element to find and remove from this array.

Returns:

True if the element has been removed.

inline void remove(uint32_t i)#

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

Parameters:

i – The position of the element that will be subtracted from this array.

inline void removeRange(uint32_t begin, uint32_t count)#

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

Parameters:
  • begin – The starting position of the element that will be subtracted from this array.

  • count – The number of elements that will be subtracted from this array.

bool resize(const uint32_t size, const T &a = T())#

Resize array.

Parameters:
  • size – New size of the array

  • a – Default value for new elements

Returns:

True if operation succeeded

bool resizeUninitialized(const uint32_t size)#

Resize array without initializing new elements.

Parameters:

size – New size of the array

Returns:

True if operation succeeded

inline bool shrink()#

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

Returns:

True if operation succeeds, false otherwise.

inline void reset()#

Deletes all array elements and frees memory.

inline void resetOrClear()#

Resets or clears the array depending on occupancy.

inline bool reserve(const uint32_t capacity)#

Ensure that the array has at least the requested capacity.

Parameters:

capacity – Minimum capacity to reserve

Returns:

True if operation succeeds, false otherwise.

inline uint32_t capacity() const#

Query the capacity(allocated mem) for the array.

Returns:

The capacity of the array

inline void forceSize_Unsafe(uint32_t size)#

Unsafe function to force the size of the array.

Parameters:

size – New size to force

inline void swap(PxArray<T, Alloc> &other)#

Swap contents of an array without allocating temporary storage.

Parameters:

other – Array to swap with

inline bool assign(const T *first, const T *last)#

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

Parameters:
  • first – Pointer to the first element to copy

  • last – Pointer past the last element to copy

Returns:

True if operation succeeds, false otherwise.

inline uint32_t isInUserMemory() const#
inline Alloc &getAllocator()#

return reference to allocator

Protected Functions

template<class A>
void copy(const PxArray<T, A> &other)#
inline T *allocate(uint32_t size, uint32_t *cookie = NULL)#
inline void deallocate(void *mem, uint32_t *cookie = NULL)#
T *growAndPushBack(const T &a)#

Called when pushBack() needs to grow the array.

Parameters:

a – The element that will be added to this array.

Returns:

Pointer to the pushed element or NULL if the operation failed

inline bool grow(uint32_t capacity)#

Resizes the available memory for the array.

Parameters:

capacity – The number of entries that the array should be able to hold.

Returns:

True if operation succeeds, false otherwise.

bool recreate(uint32_t capacity)#

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

Parameters:

capacity – The number of entries that the array should be able to hold.

Returns:

True if operation succeeds, false otherwise.

inline uint32_t capacityIncrement() const#

Protected Attributes

T *mData#
uint32_t mSize#
uint32_t mCapacity#

Protected Static Functions

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