ezEngine  Milestone 7
ezArrayPtr< 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

typedef T ElementType
 
typedef ezTypeTraits< T >
::NonConstType 
MutableElementType
 
typedef const T * const_iterator
 
typedef
const_reverse_pointer_iterator
< T > 
const_reverse_iterator
 
typedef T * iterator
 
typedef
reverse_pointer_iterator< T > 
reverse_iterator
 

Public Member Functions

 EZ_DECLARE_POD_TYPE ()
 
EZ_FORCE_INLINE ezArrayPtr ()
 Initializes the ezArrayPtr to be empty.
 
 ezArrayPtr (T *ptr, ezUInt32 uiCount)
 Initializes the ezArrayPtr with the given pointer and number of elements. No memory is allocated or copied.
 
template<size_t N>
EZ_FORCE_INLINE ezArrayPtr (T(&staticArray)[N])
 Initializes the ezArrayPtr to encapsulate the given array.
 
EZ_FORCE_INLINE ezArrayPtr (const ezArrayPtr< T > &other)
 Initializes the ezArrayPtr to be a copy of other. No memory is allocated or copied.
 
 operator ezArrayPtr< const T > () const
 Convert to const version.
 
EZ_FORCE_INLINE void operator= (const ezArrayPtr< T > &other)
 Copies the pointer and size of /a other. Does not allocate any data.
 
EZ_FORCE_INLINE const T * GetPtr () const
 Returns the pointer to the array.
 
EZ_FORCE_INLINE T * GetPtr ()
 Returns the pointer to the array.
 
EZ_FORCE_INLINE bool IsEmpty () const
 Returns whether the array is empty.
 
EZ_FORCE_INLINE ezUInt32 GetCount () const
 Returns the number of elements in the array.
 
EZ_FORCE_INLINE ezArrayPtr
< const T > 
GetSubArray (ezUInt32 uiStart, ezUInt32 uiCount) const
 Creates a sub-array from this array.
 
EZ_FORCE_INLINE ezArrayPtr< T > GetSubArray (ezUInt32 uiStart, ezUInt32 uiCount)
 Creates a sub-array from this array.
 
EZ_FORCE_INLINE ezArrayPtr
< const T > 
GetSubArray (ezUInt32 uiStart) const
 Creates a sub-array from this array. More...
 
EZ_FORCE_INLINE ezArrayPtr< T > GetSubArray (ezUInt32 uiStart)
 Creates a sub-array from this array. More...
 
EZ_FORCE_INLINE const T & operator[] (ezUInt32 uiIndex) const
 Index access.
 
EZ_FORCE_INLINE T & operator[] (ezUInt32 uiIndex)
 Index access.
 
bool operator== (const ezArrayPtr< const T > &other) const
 Compares the two arrays for equality.
 
EZ_FORCE_INLINE bool operator!= (const ezArrayPtr< const T > &other) const
 Compares the two arrays for inequality.
 
void CopyFrom (const ezArrayPtr< const T > &other)
 Copies the data from other into this array. The arrays must have the exact same size.
 
EZ_FORCE_INLINE void Reset ()
 Resets the ezArray to be empty.
 

Private Attributes

T * m_ptr
 
ezUInt32 m_uiCount
 

Detailed Description

template<typename T>
class ezArrayPtr< 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 ezArrayPtr only allows for easier access.

Member Function Documentation

template<typename T>
EZ_FORCE_INLINE ezArrayPtr<const T> ezArrayPtr< T >::GetSubArray ( ezUInt32  uiStart) const
inline

Creates a sub-array from this array.

Note
ap.GetSubArray(i)
is equivalent to
ap.GetSubArray(i, ap.GetCount() - i)
.
template<typename T>
EZ_FORCE_INLINE ezArrayPtr<T> ezArrayPtr< T >::GetSubArray ( ezUInt32  uiStart)
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: