![]() |
Plasma Engine
2.0
|
This class encapsulates an array and it's size. It is recommended to use this class instead of plain C arrays. More...
#include <ArrayPtr.h>
Public Types | |
using | ByteType = typename plArrayPtrDetail::ByteTypeHelper<T>::type |
using | ValueType = T |
using | PointerType = T* |
using | const_iterator = const T* |
using | const_reverse_iterator = const_reverse_pointer_iterator<T> |
using | iterator = T* |
using | reverse_iterator = reverse_pointer_iterator<T> |
Public Member Functions | |
PL_DECLARE_POD_TYPE () | |
PL_ALWAYS_INLINE | plArrayPtr () |
Initializes the plArrayPtr to be empty. | |
PL_ALWAYS_INLINE | plArrayPtr (const plArrayPtr< T > &other) |
Copies the pointer and size of /a other. Does not allocate any data. | |
plArrayPtr (T *pPtr, plUInt32 uiCount) | |
Initializes the plArrayPtr with the given pointer and number of elements. No memory is allocated or copied. | |
template<size_t N> | |
PL_ALWAYS_INLINE | plArrayPtr (T(&staticArray)[N]) |
Initializes the plArrayPtr to encapsulate the given array. | |
template<typename U > | |
PL_ALWAYS_INLINE | plArrayPtr (const plArrayPtr< U > &other) |
Initializes the plArrayPtr to be a copy of other. No memory is allocated or copied. | |
operator plArrayPtr< const T > () const | |
Convert to const version. | |
PL_ALWAYS_INLINE void | operator= (const plArrayPtr< T > &other) |
Copies the pointer and size of /a other. Does not allocate any data. | |
PL_ALWAYS_INLINE void | Clear () |
Clears the array. | |
PL_ALWAYS_INLINE void | operator= (std::nullptr_t) |
PL_ALWAYS_INLINE PointerType | GetPtr () const |
Returns the pointer to the array. | |
PL_ALWAYS_INLINE PointerType | GetPtr () |
Returns the pointer to the array. | |
PL_ALWAYS_INLINE PointerType | GetEndPtr () |
Returns the pointer behind the last element of the array. | |
PL_ALWAYS_INLINE PointerType | GetEndPtr () const |
Returns the pointer behind the last element of the array. | |
PL_ALWAYS_INLINE bool | IsEmpty () const |
Returns whether the array is empty. | |
PL_ALWAYS_INLINE plUInt32 | GetCount () const |
Returns the number of elements in the array. | |
PL_FORCE_INLINE plArrayPtr< T > | GetSubArray (plUInt32 uiStart, plUInt32 uiCount) const |
Creates a sub-array from this array. | |
PL_FORCE_INLINE plArrayPtr< T > | GetSubArray (plUInt32 uiStart) const |
Creates a sub-array from this array. | |
PL_ALWAYS_INLINE plArrayPtr< const ByteType > | ToByteArray () const |
Reinterprets this array as a byte array. | |
PL_ALWAYS_INLINE plArrayPtr< ByteType > | ToByteArray () |
Reinterprets this array as a byte array. | |
template<typename U > | |
PL_ALWAYS_INLINE plArrayPtr< U > | Cast () |
Cast an ArrayPtr to an ArrayPtr to a different, but same size, type. | |
template<typename U > | |
PL_ALWAYS_INLINE plArrayPtr< const U > | Cast () const |
Cast an ArrayPtr to an ArrayPtr to a different, but same size, type. | |
PL_FORCE_INLINE const ValueType & | operator[] (plUInt32 uiIndex) const |
Index access. | |
PL_FORCE_INLINE ValueType & | operator[] (plUInt32 uiIndex) |
Index access. | |
template<typename = typename std::enable_if<std::is_const<T>::value == false>> | |
bool | operator== (const plArrayPtr< const T > &other) const |
Compares the two arrays for equality. | |
bool | operator== (const plArrayPtr< T > &other) const |
Compares the two arrays for equality. | |
PL_ADD_DEFAULT_OPERATOR_NOTEQUAL (const plArrayPtr< T > &) | |
bool | operator< (const plArrayPtr< const T > &other) const |
Compares the two arrays for less. | |
void | CopyFrom (const plArrayPtr< const T > &other) |
Copies the data from other into this array. The arrays must have the exact same size. | |
PL_ALWAYS_INLINE void | Swap (plArrayPtr< T > &other) |
PL_ALWAYS_INLINE bool | Contains (const T &value) const |
Checks whether the given value can be found in the array. O(n) complexity. | |
plUInt32 | IndexOf (const T &value, plUInt32 uiStartIndex=0) const |
Searches for the first occurrence of the given value and returns its index or plInvalidIndex if not found. | |
plUInt32 | LastIndexOf (const T &value, plUInt32 uiStartIndex=plInvalidIndex) const |
Searches for the last occurrence of the given value and returns its index or plInvalidIndex if not found. | |
This class encapsulates an array and it's size. It is recommended to use this class instead of plain C arrays.
No data is deallocated at destruction, the plArrayPtr only allows for easier access.
|
inline |
Creates a sub-array from this array.