Ark Server API (ASE) - Wiki
Loading...
Searching...
No Matches
TIndirectArray< T, Allocator > Class Template Reference

#include <TIndirectArray.h>

+ Collaboration diagram for TIndirectArray< T, Allocator >:

Public Types

typedef T ElementType
 
typedef TArray< void *, Allocator > InternalArrayType
 
typedef TIndexedContainerIterator< TIndirectArray, ElementType, int32TIterator
 
typedef TIndexedContainerIterator< const TIndirectArray, const ElementType, int32TConstIterator
 

Public Member Functions

 TIndirectArray ()=default
 
 TIndirectArray (TIndirectArray &&)=default
 
TIndirectArrayoperator= (TIndirectArray &&)=default
 
 TIndirectArray (const TIndirectArray &Other)
 
TIndirectArrayoperator= (const TIndirectArray &Other)
 
 ~TIndirectArray ()
 
FORCEINLINE int32 Num () const
 
FORCEINLINE T ** GetData ()
 
FORCEINLINE const T ** GetData () const
 
uint32 GetTypeSize () const
 
FORCEINLINE T & operator[] (int32 Index)
 
FORCEINLINE const T & operator[] (int32 Index) const
 
FORCEINLINE ElementTypeLast (int32 IndexFromTheEnd=0)
 
FORCEINLINE const ElementTypeLast (int32 IndexFromTheEnd=0) const
 
void Shrink ()
 
void Reset (int32 NewSize=0)
 
void RemoveAt (int32 Index, int32 Count=1, bool bAllowShrinking=true)
 
void RemoveAtSwap (int32 Index, int32 Count=1, bool bAllowShrinking=true)
 
void Swap (int32 FirstIndexToSwap, int32 SecondIndexToSwap)
 
void Empty (int32 Slack=0)
 
FORCEINLINE int32 Add (T *Item)
 
FORCEINLINE void Insert (T *Item, int32 Index)
 
FORCEINLINE void Reserve (int32 Number)
 
FORCEINLINE bool IsValidIndex (int32 Index) const
 
SIZE_T GetAllocatedSize () const
 
TIterator CreateIterator ()
 
TConstIterator CreateConstIterator () const
 

Private Member Functions

void DestructAndFreeItems ()
 

Private Attributes

InternalArrayType Array
 

Friends

FORCEINLINE friend TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorTypebegin (TIndirectArray &IndirectArray)
 
FORCEINLINE friend TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorTypebegin (const TIndirectArray &IndirectArray)
 
FORCEINLINE friend TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorTypeend (TIndirectArray &IndirectArray)
 
FORCEINLINE friend TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorTypeend (const TIndirectArray &IndirectArray)
 

Detailed Description

template<typename T, typename Allocator = FDefaultAllocator>
class TIndirectArray< T, Allocator >

Definition at line 18 of file TIndirectArray.h.

Member Typedef Documentation

◆ ElementType

template<typename T , typename Allocator = FDefaultAllocator>
typedef T TIndirectArray< T, Allocator >::ElementType

Definition at line 21 of file TIndirectArray.h.

◆ InternalArrayType

template<typename T , typename Allocator = FDefaultAllocator>
typedef TArray<void*, Allocator> TIndirectArray< T, Allocator >::InternalArrayType

Definition at line 22 of file TIndirectArray.h.

◆ TConstIterator

template<typename T , typename Allocator = FDefaultAllocator>
typedef TIndexedContainerIterator<const TIndirectArray, const ElementType, int32> TIndirectArray< T, Allocator >::TConstIterator

Definition at line 317 of file TIndirectArray.h.

◆ TIterator

template<typename T , typename Allocator = FDefaultAllocator>
typedef TIndexedContainerIterator< TIndirectArray, ElementType, int32> TIndirectArray< T, Allocator >::TIterator

Definition at line 316 of file TIndirectArray.h.

Constructor & Destructor Documentation

◆ TIndirectArray() [1/3]

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray< T, Allocator >::TIndirectArray ( )
default

Default constructors.

◆ TIndirectArray() [2/3]

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray< T, Allocator >::TIndirectArray ( TIndirectArray< T, Allocator > && )
default

◆ TIndirectArray() [3/3]

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray< T, Allocator >::TIndirectArray ( const TIndirectArray< T, Allocator > & Other)
inline

Copy constructor.

Parameters
OtherOther array to copy from.

Definition at line 34 of file TIndirectArray.h.

◆ ~TIndirectArray()

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray< T, Allocator >::~TIndirectArray ( )
inline

Destructor.

Definition at line 62 of file TIndirectArray.h.

Member Function Documentation

◆ Add()

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE int32 TIndirectArray< T, Allocator >::Add ( T * Item)
inline

Adds a new item to the end of the array, possibly reallocating the whole array to fit.

Parameters
ItemThe item to add.
Returns
Index to the new item.

Definition at line 266 of file TIndirectArray.h.

◆ CreateConstIterator()

template<typename T , typename Allocator = FDefaultAllocator>
TConstIterator TIndirectArray< T, Allocator >::CreateConstIterator ( ) const
inline

Creates a const iterator for the contents of this array.

Returns
The const iterator.

Definition at line 334 of file TIndirectArray.h.

◆ CreateIterator()

template<typename T , typename Allocator = FDefaultAllocator>
TIterator TIndirectArray< T, Allocator >::CreateIterator ( )
inline

Creates an iterator for the contents of this array.

Returns
The iterator.

Definition at line 324 of file TIndirectArray.h.

◆ DestructAndFreeItems()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::DestructAndFreeItems ( )
inlineprivate

Calls destructor and frees memory on every element in the array.

Definition at line 344 of file TIndirectArray.h.

◆ Empty()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::Empty ( int32 Slack = 0)
inline

Empties the array. It calls the destructors on held items.

Parameters
Slack(Optional) The expected usage size after empty operation. Default is 0.

Definition at line 253 of file TIndirectArray.h.

◆ GetAllocatedSize()

template<typename T , typename Allocator = FDefaultAllocator>
SIZE_T TIndirectArray< T, Allocator >::GetAllocatedSize ( ) const
inline

Helper function to return the amount of memory allocated by this container

Returns
Number of bytes allocated by this container.

Definition at line 310 of file TIndirectArray.h.

◆ GetData() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE T ** TIndirectArray< T, Allocator >::GetData ( )
inline

Helper function for returning a typed pointer to the first array entry.

Returns
Pointer to first array entry or nullptr if this->ArrayMax == 0.

Definition at line 82 of file TIndirectArray.h.

◆ GetData() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE const T ** TIndirectArray< T, Allocator >::GetData ( ) const
inline

Helper function for returning a typed pointer to the first array entry.

Returns
Pointer to first array entry or nullptr if this->ArrayMax == 0.

Definition at line 92 of file TIndirectArray.h.

◆ GetTypeSize()

template<typename T , typename Allocator = FDefaultAllocator>
uint32 TIndirectArray< T, Allocator >::GetTypeSize ( ) const
inline

Helper function returning the size of the inner type.

Returns
Size in bytes of array type.

Definition at line 102 of file TIndirectArray.h.

◆ Insert()

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE void TIndirectArray< T, Allocator >::Insert ( T * Item,
int32 Index )
inline

Inserts a given element into the array at given location.

Parameters
ItemThe element to insert.
IndexTells where to insert the new elements.

Definition at line 277 of file TIndirectArray.h.

◆ IsValidIndex()

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE bool TIndirectArray< T, Allocator >::IsValidIndex ( int32 Index) const
inline

Tests if index is valid, i.e. greater than zero and less than number of elements in array.

Parameters
IndexIndex to test.
Returns
True if index is valid. False otherwise.

Definition at line 300 of file TIndirectArray.h.

◆ Last() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE ElementType & TIndirectArray< T, Allocator >::Last ( int32 IndexFromTheEnd = 0)
inline

Returns n-th last element from the array.

Parameters
IndexFromTheEnd(Optional) Index from the end of array (default = 0).
Returns
Reference to n-th last element from the array.

Definition at line 137 of file TIndirectArray.h.

◆ Last() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE const ElementType & TIndirectArray< T, Allocator >::Last ( int32 IndexFromTheEnd = 0) const
inline

Returns n-th last element from the array.

Const version.

Parameters
IndexFromTheEnd(Optional) Index from the end of array (default = 0).
Returns
Reference to n-th last element from the array.

Definition at line 150 of file TIndirectArray.h.

◆ Num()

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE int32 TIndirectArray< T, Allocator >::Num ( ) const
inline

Gets number of elements in array.

Returns
Number of elements in array.

Definition at line 72 of file TIndirectArray.h.

◆ operator=() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray & TIndirectArray< T, Allocator >::operator= ( const TIndirectArray< T, Allocator > & Other)
inline

Assignment operator.

Parameters
OtherOther array to assign with.

Definition at line 47 of file TIndirectArray.h.

◆ operator=() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
TIndirectArray & TIndirectArray< T, Allocator >::operator= ( TIndirectArray< T, Allocator > && )
default

◆ operator[]() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE T & TIndirectArray< T, Allocator >::operator[] ( int32 Index)
inline

Bracket array access operator.

Parameters
IndexPosition of element to return.
Returns
Reference to element in array at given position.

Definition at line 113 of file TIndirectArray.h.

◆ operator[]() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE const T & TIndirectArray< T, Allocator >::operator[] ( int32 Index) const
inline

Bracket array access operator.

Const version.

Parameters
IndexPosition of element to return.
Returns
Reference to element in array at given position.

Definition at line 126 of file TIndirectArray.h.

◆ RemoveAt()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAt ( int32 Index,
int32 Count = 1,
bool bAllowShrinking = true )
inline

Removes an element (or elements) at given location optionally shrinking the array.

Parameters
IndexLocation in array of the element to remove.
Count(Optional) Number of elements to remove. Default is 1.
bAllowShrinking(Optional) Tells if this call can shrink array if suitable after remove. Default is true.

Definition at line 186 of file TIndirectArray.h.

◆ RemoveAtSwap()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAtSwap ( int32 Index,
int32 Count = 1,
bool bAllowShrinking = true )
inline

Removes an element (or elements) at given location optionally shrinking the array.

This version is much more efficient than RemoveAt (O(Count) instead of O(ArrayNum)), but does not preserve the order.

Parameters
IndexLocation in array of the element to remove.
Count(Optional) Number of elements to remove. Default is 1.
bAllowShrinking(Optional) Tells if this call can shrink array if suitable after remove. Default is true.

Definition at line 216 of file TIndirectArray.h.

◆ Reserve()

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE void TIndirectArray< T, Allocator >::Reserve ( int32 Number)
inline

Reserves memory such that the array can contain at least Number elements.

Parameters
NumberThe number of elements that the array should be able to contain after allocation.

Definition at line 288 of file TIndirectArray.h.

◆ Reset()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::Reset ( int32 NewSize = 0)
inline

Resets the array to the new given size. It calls the destructors on held items.

Parameters
NewSize(Optional) The expected usage size after calling this function. Default is 0.

Definition at line 171 of file TIndirectArray.h.

◆ Shrink()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::Shrink ( )
inline

Shrinks the array's used memory to smallest possible to store elements currently in it.

Definition at line 159 of file TIndirectArray.h.

◆ Swap()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::Swap ( int32 FirstIndexToSwap,
int32 SecondIndexToSwap )
inline

Element-wise array element swap.

This version is doing more sanity checks than SwapMemory.

Parameters
FirstIndexToSwapPosition of the first element to swap.
SecondIndexToSwapPosition of the second element to swap.

Definition at line 242 of file TIndirectArray.h.

Friends And Related Symbol Documentation

◆ begin [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE friend TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorType > begin ( const TIndirectArray< T, Allocator > & IndirectArray)
friend

Definition at line 363 of file TIndirectArray.h.

◆ begin [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE friend TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorType > begin ( TIndirectArray< T, Allocator > & IndirectArray)
friend

DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.

Definition at line 362 of file TIndirectArray.h.

◆ end [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE friend TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorType > end ( const TIndirectArray< T, Allocator > & IndirectArray)
friend

Definition at line 365 of file TIndirectArray.h.

◆ end [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
FORCEINLINE friend TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorType > end ( TIndirectArray< T, Allocator > & IndirectArray)
friend

Definition at line 364 of file TIndirectArray.h.

Member Data Documentation

◆ Array

template<typename T , typename Allocator = FDefaultAllocator>
InternalArrayType TIndirectArray< T, Allocator >::Array
private

Definition at line 367 of file TIndirectArray.h.


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