UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TIndirectArray< T, Allocator > Class Template Reference

#include <IndirectArray.h>

Public Types

typedefElementType
 
typedef TArray< void *, AllocatorInternalArrayType
 
typedef TIndexedContainerIterator< TIndirectArray, ElementType, int32TIterator
 
typedef TIndexedContainerIterator< const TIndirectArray, const ElementType, int32TConstIterator
 

Public Member Functions

 TIndirectArray ()=default
 
 TIndirectArray (TIndirectArray &&)=default
 
 TIndirectArray (const TIndirectArray &Other)
 
TIndirectArrayoperator= (const TIndirectArray &Other)
 
TIndirectArrayoperator= (TIndirectArray &&Other)
 
 ~TIndirectArray ()
 
bool IsEmpty () const
 
UE_FORCEINLINE_HINT int32 Num () const
 
UE_FORCEINLINE_HINT T ** GetData ()
 
UE_FORCEINLINE_HINT const T ** GetData () const
 
UE_FORCEINLINE_HINT T & operator[] (int32 Index)
 
UE_FORCEINLINE_HINT const T & operator[] (int32 Index) const
 
UE_FORCEINLINE_HINT ElementTypeLast (int32 IndexFromTheEnd=0)
 
UE_FORCEINLINE_HINT const ElementTypeLast (int32 IndexFromTheEnd=0) const
 
void Shrink ()
 
void Reset (int32 NewSize=0)
 
void Serialize (FArchive &Ar, UObject *Owner)
 
void CountBytes (FArchive &Ar) const
 
void RemoveAt (int32 Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< Allocator >())
 
void RemoveAt (int32 Index, int32 Count, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< Allocator >())
 
UE_FORCEINLINE_HINT void RemoveAt (int32 Index, int32 Count, bool bAllowShrinking)
 
void RemoveAtSwap (int32 Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< Allocator >())
 
void RemoveAtSwap (int32 Index, int32 Count, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< Allocator >())
 
UE_FORCEINLINE_HINT void RemoveAtSwap (int32 Index, int32 Count, bool bAllowShrinking)
 
void Swap (int32 FirstIndexToSwap, int32 SecondIndexToSwap)
 
void Empty (int32 Slack=0)
 
UE_FORCEINLINE_HINT int32 Add (T *Item)
 
UE_FORCEINLINE_HINT void Insert (T *Item, int32 Index)
 
UE_FORCEINLINE_HINT void Reserve (int32 Number)
 
UE_FORCEINLINE_HINT bool IsValidIndex (int32 Index) const
 
SIZE_T GetAllocatedSize () const
 
TIterator CreateIterator ()
 
TConstIterator CreateConstIterator () const
 
UE_FORCEINLINE_HINT TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorTypebegin ()
 
UE_FORCEINLINE_HINT TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorTypebegin () const
 
UE_FORCEINLINE_HINT TDereferencingIterator< ElementType, typename InternalArrayType::RangedForIteratorTypeend ()
 
UE_FORCEINLINE_HINT TDereferencingIterator< const ElementType, typename InternalArrayType::RangedForConstIteratorTypeend () const
 

Static Public Member Functions

static constexpr uint32 GetTypeSize ()
 

Member Typedef Documentation

◆ ElementType

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

◆ InternalArrayType

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

◆ TConstIterator

◆ TIterator

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.

◆ ~TIndirectArray()

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

Destructor.

Member Function Documentation

◆ Add()

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ begin() [1/2]

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

◆ begin() [2/2]

◆ CountBytes()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::CountBytes ( FArchive Ar) const
inline

Count bytes needed to serialize this array.

Parameters
ArArchive to count for.

◆ 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.

◆ 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.

◆ 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.

◆ end() [1/2]

◆ end() [2/2]

◆ 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.

◆ GetData() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ GetData() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ GetTypeSize()

template<typename T , typename Allocator = FDefaultAllocator>
static constexpr uint32 TIndirectArray< T, Allocator >::GetTypeSize ( )
inlinestaticconstexpr

Helper function returning the size of the inner type.

Returns
Size in bytes of array type.

◆ Insert()

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ IsEmpty()

template<typename T , typename Allocator = FDefaultAllocator>
bool TIndirectArray< T, Allocator >::IsEmpty ( ) const
inline

Returns true if the array is empty and contains no elements.

Returns
True if the array is empty.
See also
Num

◆ IsValidIndex()

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ Last() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ Last() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ Num()

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

Gets number of elements in array.

Returns
Number of elements in array.

◆ operator=() [1/2]

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

Assignment operators.

Parameters
OtherOther array to assign with.

◆ operator=() [2/2]

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

◆ operator[]() [1/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ operator[]() [2/2]

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ RemoveAt() [1/3]

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAt ( int32  Index,
EAllowShrinking  AllowShrinking = UE::Core::Private::AllowShrinkingByDefault<Allocator>() 
)
inline

Removes an element at given location optionally shrinking the array.

Parameters
IndexLocation in array of the element to remove.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.

◆ RemoveAt() [2/3]

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

◆ RemoveAt() [3/3]

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAt ( int32  Index,
int32  Count,
EAllowShrinking  AllowShrinking = UE::Core::Private::AllowShrinkingByDefault<Allocator>() 
)
inline

Removes elements at given location optionally shrinking the array.

Parameters
IndexLocation in array of the first element to remove.
CountNumber of elements to remove.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.

◆ RemoveAtSwap() [1/3]

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAtSwap ( int32  Index,
EAllowShrinking  AllowShrinking = UE::Core::Private::AllowShrinkingByDefault<Allocator>() 
)
inline

Removes an element 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.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.

◆ RemoveAtSwap() [2/3]

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

◆ RemoveAtSwap() [3/3]

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::RemoveAtSwap ( int32  Index,
int32  Count,
EAllowShrinking  AllowShrinking = UE::Core::Private::AllowShrinkingByDefault<Allocator>() 
)
inline

Removes 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 rirst element to remove.
CountNumber of elements to remove.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.

◆ Reserve()

template<typename T , typename Allocator = FDefaultAllocator>
UE_FORCEINLINE_HINT 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.

◆ 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.

◆ Serialize()

template<typename T , typename Allocator = FDefaultAllocator>
void TIndirectArray< T, Allocator >::Serialize ( FArchive Ar,
UObject Owner 
)
inline

Special serialize function passing the owning UObject along as required by FUnytpedBulkData serialization.

Parameters
ArArchive to serialize with.
OwnerUObject this structure is serialized within.

◆ 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.

◆ 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.

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