XII Release 0.1.0
Loading...
Searching...
No Matches
xiiSmallArray< T, Size, AllocatorWrapper > Class Template Reference

#include <SmallArray.h>

Inheritance diagram for xiiSmallArray< T, Size, AllocatorWrapper >:
[legend]

Public Member Functions

 XII_DECLARE_MEM_RELOCATABLE_TYPE_CONDITIONAL (T)
 
 xiiSmallArray (const xiiSmallArray< T, Size, AllocatorWrapper > &other)
 
 xiiSmallArray (const xiiArrayPtr< const T > &other)
 
 xiiSmallArray (xiiSmallArray< T, Size, AllocatorWrapper > &&other)
 
void operator= (const xiiSmallArray< T, Size, AllocatorWrapper > &rhs)
 
void operator= (const xiiArrayPtr< const T > &rhs)
 
void operator= (xiiSmallArray< T, Size, AllocatorWrapper > &&rhs) noexcept
 
void SetCount (xiiUInt16 uiCount)
 
void SetCount (xiiUInt16 uiCount, const T &fillValue)
 
void EnsureCount (xiiUInt16 uiCount)
 
template<typename = void>
void SetCountUninitialized (xiiUInt16 uiCount)
 
void InsertAt (xiiUInt32 uiIndex, const T &value)
 
void InsertAt (xiiUInt32 uiIndex, T &&value)
 
T & ExpandAndGetRef ()
 
void PushBack (const T &value)
 
void PushBack (T &&value)
 
void PushBackRange (const xiiArrayPtr< const T > &range)
 
void Reserve (xiiUInt16 uiCapacity)
 
void Compact ()
 
template<typename>
XII_ALWAYS_INLINE void SetCountUninitialized (xiiUInt16 uiCount)
 
- Public Member Functions inherited from xiiSmallArrayBase< T, Size >
 XII_DECLARE_MEM_RELOCATABLE_TYPE_CONDITIONAL (T)
 
 xiiSmallArrayBase (const xiiSmallArrayBase< T, Size > &other, xiiAllocatorBase *pAllocator)
 
 xiiSmallArrayBase (const xiiArrayPtr< const T > &other, xiiAllocatorBase *pAllocator)
 
 xiiSmallArrayBase (xiiSmallArrayBase< T, Size > &&other, xiiAllocatorBase *pAllocator)
 
void operator= (const xiiSmallArrayBase< T, Size > &rhs)=delete
 
void operator= (xiiSmallArrayBase< T, Size > &&rhs)=delete
 
void CopyFrom (const xiiArrayPtr< const T > &other, xiiAllocatorBase *pAllocator)
 Copies the data from some other array into this one.
 
void MoveFrom (xiiSmallArrayBase< T, Size > &&other, xiiAllocatorBase *pAllocator)
 Moves the data from some other array into this one.
 
 operator xiiArrayPtr< const T > () const
 Conversion to const xiiArrayPtr.
 
 operator xiiArrayPtr< T > ()
 Conversion to xiiArrayPtr.
 
bool operator== (const xiiSmallArrayBase< T, Size > &rhs) const
 Compares this array to another contiguous array type.
 
const T & operator[] (xiiUInt32 uiIndex) const
 Returns the element at the given index. Does bounds checks in debug builds.
 
T & operator[] (xiiUInt32 uiIndex)
 Returns the element at the given index. Does bounds checks in debug builds.
 
void SetCount (xiiUInt16 uiCount, xiiAllocatorBase *pAllocator)
 Resizes the array to have exactly uiCount elements. Default constructs extra elements if the array is grown.
 
void SetCount (xiiUInt16 uiCount, const T &fillValue, xiiAllocatorBase *pAllocator)
 Resizes the array to have exactly uiCount elements. Constructs all new elements by copying the FillValue.
 
template<typename = void>
void SetCountUninitialized (xiiUInt16 uiCount, xiiAllocatorBase *pAllocator)
 Resizes the array to have exactly uiCount elements. Extra elements might be uninitialized.
 
void EnsureCount (xiiUInt16 uiCount, xiiAllocatorBase *pAllocator)
 Ensures the container has at least uiCount elements. Ie. calls SetCount() if the container has fewer elements, does nothing otherwise.
 
xiiUInt32 GetCount () const
 Returns the number of active elements in the array.
 
bool IsEmpty () const
 Returns true, if the array does not contain any elements.
 
void Clear ()
 Clears the array.
 
bool Contains (const T &value) const
 Checks whether the given value can be found in the array. O(n) complexity.
 
void Insert (const T &value, xiiUInt32 uiIndex, xiiAllocatorBase *pAllocator)
 Inserts value at index by shifting all following elements.
 
void Insert (T &&value, xiiUInt32 uiIndex, xiiAllocatorBase *pAllocator)
 Inserts value at index by shifting all following elements.
 
bool RemoveAndCopy (const T &value)
 Removes the first occurrence of value and fills the gap by shifting all following elements.
 
bool RemoveAndSwap (const T &value)
 Removes the first occurrence of value and fills the gap by swapping in the last element.
 
void RemoveAtAndCopy (xiiUInt32 uiIndex, xiiUInt16 uiNumElements=1)
 Removes the element at index and fills the gap by shifting all following elements.
 
void RemoveAtAndSwap (xiiUInt32 uiIndex, xiiUInt16 uiNumElements=1)
 Removes the element at index and fills the gap by swapping in the last element.
 
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=xiiSmallInvalidIndex) const
 Searches for the last occurrence of the given value and returns its index or xiiInvalidIndex if not found.
 
T & ExpandAndGetRef (xiiAllocatorBase *pAllocator)
 Grows the array by one element and returns a reference to the newly created element.
 
void PushBack (const T &value, xiiAllocatorBase *pAllocator)
 Pushes value at the end of the array.
 
void PushBack (T &&value, xiiAllocatorBase *pAllocator)
 Pushes value at the end of the array.
 
void PushBackUnchecked (const T &value)
 Pushes value at the end of the array. Does NOT ensure capacity.
 
void PushBackUnchecked (T &&value)
 Pushes value at the end of the array. Does NOT ensure capacity.
 
void PushBackRange (const xiiArrayPtr< const T > &range, xiiAllocatorBase *pAllocator)
 Pushes all elements in range at the end of the array. Increases the capacity if necessary.
 
void PopBack (xiiUInt32 uiCountToRemove=1)
 Removes count elements from the end of the array.
 
T & PeekBack ()
 Returns the last element of the array.
 
const T & PeekBack () const
 Returns the last element of the array.
 
template<typename Comparer>
void Sort (const Comparer &comparer)
 Sort with explicit comparer.
 
void Sort ()
 Sort with default comparer.
 
T * GetData ()
 Returns a pointer to the array data, or nullptr if the array is empty.
 
const T * GetData () const
 Returns a pointer to the array data, or nullptr if the array is empty.
 
xiiArrayPtr< T > GetArrayPtr ()
 Returns an array pointer to the array data, or an empty array pointer if the array is empty.
 
xiiArrayPtr< const T > GetArrayPtr () const
 Returns an array pointer to the array data, or an empty array pointer if the array is empty.
 
xiiArrayPtr< typename xiiArrayPtr< T >::ByteType > GetByteArrayPtr ()
 Returns a byte array pointer to the array data, or an empty array pointer if the array is empty.
 
xiiArrayPtr< typename xiiArrayPtr< const T >::ByteType > GetByteArrayPtr () const
 Returns a byte array pointer to the array data, or an empty array pointer if the array is empty.
 
void Reserve (xiiUInt16 uiCapacity, xiiAllocatorBase *pAllocator)
 Expands the array so it can at least store the given capacity.
 
void Compact (xiiAllocatorBase *pAllocator)
 Tries to compact the array to avoid wasting memory. The resulting capacity is at least 'GetCount' (no elements get removed). Will deallocate all data, if the array is empty.
 
xiiUInt32 GetCapacity () const
 Returns the reserved number of elements that the array can hold without reallocating.
 
xiiUInt64 GetHeapMemoryUsage () const
 Returns the amount of bytes that are currently allocated on the heap.
 
template<typename U>
const U & GetUserData () const
 
template<typename U>
U & GetUserData ()
 
template<typename U>
XII_ALWAYS_INLINE const U & GetUserData () const
 
template<typename U>
XII_ALWAYS_INLINE U & GetUserData ()
 

Additional Inherited Members

- Public Types inherited from xiiSmallArrayBase< T, Size >
using value_type = T
 
using const_reference = const 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>
 
- Protected Types inherited from xiiSmallArrayBase< T, Size >
enum  { CAPACITY_ALIGNMENT = 4 }
 
- Protected Member Functions inherited from xiiSmallArrayBase< T, Size >
void SetCapacity (xiiUInt16 uiCapacity, xiiAllocatorBase *pAllocator)
 
T * GetElementsPtr ()
 
const T * GetElementsPtr () const
 
- Protected Attributes inherited from xiiSmallArrayBase< T, Size >
xiiUInt16 m_uiCount = 0
 
xiiUInt16 m_uiCapacity = Size
 
xiiUInt32 m_uiUserData = 0
 
union { 
 
   struct alignas
 
      xiiUInt8   m_StaticData [Size *sizeof(T)] 
 
   }  
 
   T *   m_pElements = nullptr 
 
};  
 

Detailed Description

template<typename T, xiiUInt16 Size, typename AllocatorWrapper = xiiDefaultAllocatorWrapper>
class xiiSmallArray< T, Size, AllocatorWrapper >
See also
xiiSmallArrayBase

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