XII Release 0.1.0
Loading...
Searching...
No Matches
xiiArrayPtr< T > Class Template Reference

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 xiiArrayPtrDetail::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

 XII_DECLARE_POD_TYPE ()
 
XII_ALWAYS_INLINE xiiArrayPtr ()
 Initializes the xiiArrayPtr to be empty.
 
XII_ALWAYS_INLINE xiiArrayPtr (const xiiArrayPtr< T > &other)
 Copies the pointer and size of /a other. Does not allocate any data.
 
 xiiArrayPtr (T *pPtr, xiiUInt32 uiCount)
 Initializes the xiiArrayPtr with the given pointer and number of elements. No memory is allocated or copied.
 
template<size_t N>
XII_ALWAYS_INLINE xiiArrayPtr (T(&staticArray)[N])
 Initializes the xiiArrayPtr to encapsulate the given array.
 
template<typename U>
XII_ALWAYS_INLINE xiiArrayPtr (const xiiArrayPtr< U > &other)
 Initializes the xiiArrayPtr to be a copy of other. No memory is allocated or copied.
 
 operator xiiArrayPtr< const T > () const
 Convert to const version.
 
XII_ALWAYS_INLINE void operator= (const xiiArrayPtr< T > &other)
 Copies the pointer and size of /a other. Does not allocate any data.
 
XII_ALWAYS_INLINE void Clear ()
 Clears the array.
 
XII_ALWAYS_INLINE void operator= (std::nullptr_t)
 
XII_ALWAYS_INLINE PointerType GetPtr () const
 Returns the pointer to the array.
 
XII_ALWAYS_INLINE PointerType GetPtr ()
 Returns the pointer to the array.
 
XII_ALWAYS_INLINE PointerType GetEndPtr ()
 Returns the pointer behind the last element of the array.
 
XII_ALWAYS_INLINE PointerType GetEndPtr () const
 Returns the pointer behind the last element of the array.
 
XII_ALWAYS_INLINE bool IsEmpty () const
 Returns whether the array is empty.
 
XII_ALWAYS_INLINE xiiUInt32 GetCount () const
 Returns the number of elements in the array.
 
XII_FORCE_INLINE xiiArrayPtr< T > GetSubArray (xiiUInt32 uiStart, xiiUInt32 uiCount) const
 Creates a sub-array from this array.
 
XII_FORCE_INLINE xiiArrayPtr< T > GetSubArray (xiiUInt32 uiStart) const
 Creates a sub-array from this array.
 
XII_ALWAYS_INLINE xiiArrayPtr< const ByteType > ToByteArray () const
 Reinterprets this array as a byte array.
 
XII_ALWAYS_INLINE xiiArrayPtr< ByteType > ToByteArray ()
 Reinterprets this array as a byte array.
 
template<typename U>
XII_ALWAYS_INLINE xiiArrayPtr< U > Cast ()
 Cast an ArrayPtr to an ArrayPtr to a different, but same size, type.
 
template<typename U>
XII_ALWAYS_INLINE xiiArrayPtr< const U > Cast () const
 Cast an ArrayPtr to an ArrayPtr to a different, but same size, type.
 
XII_FORCE_INLINE const ValueType & operator[] (xiiUInt32 uiIndex) const
 Index access.
 
XII_FORCE_INLINE ValueType & operator[] (xiiUInt32 uiIndex)
 Index access.
 
template<typename = typename std::enable_if<std::is_const<T>::value == false>>
bool operator== (const xiiArrayPtr< const T > &other) const
 Compares the two arrays for equality.
 
bool operator== (const xiiArrayPtr< T > &other) const
 Compares the two arrays for equality.
 
bool operator< (const xiiArrayPtr< const T > &other) const
 Compares the two arrays for less.
 
void CopyFrom (const xiiArrayPtr< const T > &other)
 Copies the data from other into this array. The arrays must have the exact same size.
 
XII_ALWAYS_INLINE void Swap (xiiArrayPtr< T > &other)
 
XII_ALWAYS_INLINE bool Contains (const T &value) const
 Checks whether the given value can be found in the array. O(n) complexity.
 
xiiUInt32 IndexOf (const T &value, xiiUInt32 uiStartIndex=0) const
 Searches for the first occurrence of the given value and returns its index or xiiInvalidIndex if not found.
 
xiiUInt32 LastIndexOf (const T &value, xiiUInt32 uiStartIndex=xiiInvalidIndex) const
 Searches for the last occurrence of the given value and returns its index or xiiInvalidIndex if not found.
 

Detailed Description

template<typename T>
class xiiArrayPtr< T >

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 xiiArrayPtr only allows for easier access.

Member Function Documentation

◆ GetSubArray()

template<typename T>
XII_FORCE_INLINE xiiArrayPtr< T > xiiArrayPtr< T >::GetSubArray ( xiiUInt32 uiStart) const
inline

Creates a sub-array from this array.

Note
ap.GetSubArray(i)
is equivalent to
ap.GetSubArray(i, ap.GetCount() - i)
.

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