UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TArray< InElementType, InAllocatorType > Class Template Reference

#include <Array.h>

+ Inheritance diagram for TArray< InElementType, InAllocatorType >:

Public Types

using SizeType = typename InAllocatorType::SizeType
 
using ElementType = InElementType
 
using AllocatorType = InAllocatorType
 
using ElementAllocatorType = std::conditional_t< AllocatorType::NeedsElementType, typename AllocatorType::template ForElementType< ElementType >, typename AllocatorType::ForAnyElementType >
 
using IntrusiveUnsetOptionalStateType = TArray
 
using TIterator = TIndexedContainerIterator< TArray, ElementType, SizeType >
 
using TConstIterator = TIndexedContainerIterator< const TArray, const ElementType, SizeType >
 
using RangedForIteratorType = TCheckedPointerIterator< ElementType, SizeType, false >
 
using RangedForConstIteratorType = TCheckedPointerIterator< const ElementType, SizeType, false >
 
using RangedForReverseIteratorType = TCheckedPointerIterator< ElementType, SizeType, true >
 
using RangedForConstReverseIteratorType = TCheckedPointerIterator< const ElementType, SizeType, true >
 

Public Member Functions

UE_FORCEINLINE_HINT constexpr TArray ()
 
consteval TArray (EConstEval)
 
UE_FORCEINLINE_HINT TArray (const ElementType *Ptr, SizeType Count)
 
template<typename OtherElementType , typename OtherSizeType >
 TArray (const TArrayView< OtherElementType, OtherSizeType > &Other)
 
 TArray (std::initializer_list< InElementType > InitList)
 
template<typename OtherElementType , typename OtherAllocator >
UE_FORCEINLINE_HINT TArray (const TArray< OtherElementType, OtherAllocator > &Other)
 
UE_FORCEINLINE_HINT TArray (const TArray &Other)
 
UE_FORCEINLINE_HINT TArray (const TArray &Other, SizeType ExtraSlack)
 
TArrayoperator= (std::initializer_list< InElementType > InitList)
 
template<typename OtherAllocatorType >
TArrayoperator= (const TArray< ElementType, OtherAllocatorType > &Other)
 
TArrayoperator= (const TArray &Other)
 
template<typename OtherElementType , typename OtherSizeType >
TArrayoperator= (const TArrayView< OtherElementType, OtherSizeType > &Other)
 
UE_FORCEINLINE_HINT TArray (TArray &&Other)
 
template<typename OtherElementType , typename OtherAllocator >
UE_FORCEINLINE_HINT TArray (TArray< OtherElementType, OtherAllocator > &&Other)
 
template<typename OtherElementType >
 TArray (TArray< OtherElementType, AllocatorType > &&Other, SizeType ExtraSlack)
 
TArrayoperator= (TArray &&Other)
 
 ~TArray ()
 
UE_NODEBUG TArray (FIntrusiveUnsetOptionalState Tag)
 
UE_NODEBUG bool operator== (FIntrusiveUnsetOptionalState Tag) const
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeGetData () UE_LIFETIMEBOUND
 
UE_REWRITE const ElementTypeGetData () const UE_LIFETIMEBOUND
 
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T GetAllocatedSize (void) const
 
UE_NODEBUG UE_FORCEINLINE_HINT SizeType GetSlack () const
 
UE_NODEBUG UE_FORCEINLINE_HINT void CheckInvariants () const
 
UE_FORCEINLINE_HINT void RangeCheck (SizeType Index) const
 
UE_FORCEINLINE_HINT void RangeCheck (SizeType Index, SizeType Count) const
 
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex (SizeType Index) const
 
UE_REWRITE bool IsEmpty () const
 
UE_REWRITE SizeType Num () const
 
UE_NODEBUG UE_FORCEINLINE_HINT SIZE_T NumBytes () const
 
UE_REWRITE SizeType Max () const
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeoperator[] (SizeType Index) UE_LIFETIMEBOUND
 
UE_REWRITE const ElementTypeoperator[] (SizeType Index) const UE_LIFETIMEBOUND
 
ElementType Pop (EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementType Pop (bool bAllowShrinking)
 
UE_NODEBUG UE_FORCEINLINE_HINT void Push (ElementType &&Item)
 
UE_NODEBUG UE_FORCEINLINE_HINT void Push (const ElementType &Item)
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeTop () UE_LIFETIMEBOUND
 
UE_REWRITE const ElementTypeTop () const UE_LIFETIMEBOUND
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeLast (SizeType IndexFromTheEnd=0) UE_LIFETIMEBOUND
 
UE_REWRITE const ElementTypeLast (SizeType IndexFromTheEnd=0) const UE_LIFETIMEBOUND
 
UE_FORCEINLINE_HINT void Shrink ()
 
UE_NODEBUG UE_FORCEINLINE_HINT bool Find (const ElementType &Item, SizeType &Index) const
 
SizeType Find (const ElementType &Item) const
 
UE_NODEBUG UE_FORCEINLINE_HINT bool FindLast (const ElementType &Item, SizeType &Index) const
 
SizeType FindLast (const ElementType &Item) const
 
template<typename Predicate >
SizeType FindLastByPredicate (Predicate Pred, SizeType Count) const
 
template<typename Predicate >
UE_NODEBUG UE_FORCEINLINE_HINT SizeType FindLastByPredicate (Predicate Pred) const
 
template<typename KeyType >
SizeType IndexOfByKey (const KeyType &Key) const
 
template<typename Predicate >
SizeType IndexOfByPredicate (Predicate Pred) const
 
template<typename KeyType >
ElementTypeFindByKey (const KeyType &Key)
 
template<typename KeyType >
UE_REWRITE const ElementTypeFindByKey (const KeyType &Key) const
 
template<typename Predicate >
ElementTypeFindByPredicate (Predicate Pred)
 
template<typename Predicate >
UE_REWRITE const ElementTypeFindByPredicate (Predicate Pred) const
 
template<typename Predicate >
TArray< ElementTypeFilterByPredicate (Predicate Pred) const
 
template<typename ComparisonType >
bool Contains (const ComparisonType &Item) const
 
template<typename Predicate >
UE_NODEBUG UE_FORCEINLINE_HINT bool ContainsByPredicate (Predicate Pred) const
 
UE_NODEBUG bool operator== (const TArray &OtherArray) const
 
UE_REWRITE bool operator!= (const TArray &OtherArray) const
 
void BulkSerialize (FArchive &Ar, bool bForcePerElementSerialization=false)
 
UE_NODEBUG void CountBytes (FArchive &Ar) const
 
UE_FORCEINLINE_HINT SizeType AddUninitialized ()
 
UE_FORCEINLINE_HINT SizeType AddUninitialized (SizeType Count)
 
UE_NODEBUG UE_FORCEINLINE_HINT void InsertUninitialized (SizeType Index)
 
UE_NODEBUG UE_FORCEINLINE_HINT void InsertUninitialized (SizeType Index, SizeType Count)
 
void InsertZeroed (SizeType Index)
 
void InsertZeroed (SizeType Index, SizeType Count)
 
ElementTypeInsertZeroed_GetRef (SizeType Index) UE_LIFETIMEBOUND
 
void InsertDefaulted (SizeType Index)
 
void InsertDefaulted (SizeType Index, SizeType Count)
 
ElementTypeInsertDefaulted_GetRef (SizeType Index) UE_LIFETIMEBOUND
 
SizeType Insert (std::initializer_list< ElementType > InitList, const SizeType InIndex)
 
template<typename OtherAllocator >
SizeType Insert (const TArray< ElementType, OtherAllocator > &Items, const SizeType InIndex)
 
template<typename OtherAllocator >
SizeType Insert (TArray< ElementType, OtherAllocator > &&Items, const SizeType InIndex)
 
SizeType Insert (const ElementType *Ptr, SizeType Count, SizeType Index)
 
UE_FORCEINLINE_HINT void CheckAddress (const ElementType *Addr) const
 
SizeType Insert (ElementType &&Item, SizeType Index)
 
SizeType Insert (const ElementType &Item, SizeType Index)
 
ElementTypeInsert_GetRef (ElementType &&Item, SizeType Index) UE_LIFETIMEBOUND
 
ElementTypeInsert_GetRef (const ElementType &Item, SizeType Index) UE_LIFETIMEBOUND
 
void RemoveAt (SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<UE::CIntegral CountType>
UE_FORCEINLINE_HINT void RemoveAt (SizeType Index, CountType Count, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<typename CountType >
UE_FORCEINLINE_HINT void RemoveAt (SizeType Index, CountType Count, bool bAllowShrinking)
 
UE_FORCEINLINE_HINT void RemoveAtSwap (SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<UE::CIntegral CountType>
UE_FORCEINLINE_HINT void RemoveAtSwap (SizeType Index, CountType Count, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<typename CountType >
UE_NODEBUG UE_FORCEINLINE_HINT void RemoveAtSwap (SizeType Index, CountType Count, bool bAllowShrinking)
 
void Reset (SizeType NewSize=0)
 
void Empty (SizeType Slack=0)
 
void SetNum (SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void SetNum (SizeType NewNum, bool bAllowShrinking)
 
void SetNumZeroed (SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void SetNumZeroed (SizeType NewNum, bool bAllowShrinking)
 
void SetNumUninitialized (SizeType NewNum, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void SetNumUninitialized (SizeType NewNum, bool bAllowShrinking)
 
void SetNumUnsafeInternal (SizeType NewNum)
 
template<typename OtherElementType , typename OtherAllocatorType >
void Append (const TArray< OtherElementType, OtherAllocatorType > &Source)
 
template<typename OtherElementType , typename OtherAllocator >
void Append (TArray< OtherElementType, OtherAllocator > &&Source)
 
template<typename RangeType UE_REQUIRES>
void Append (RangeType &&Source)
 
void Append (const ElementType *Ptr, SizeType Count)
 
UE_FORCEINLINE_HINT void Append (std::initializer_list< ElementType > InitList)
 
UE_NODEBUG TArrayoperator+= (TArray &&Other)
 
UE_NODEBUG TArrayoperator+= (const TArray &Other)
 
UE_NODEBUG TArrayoperator+= (std::initializer_list< ElementType > InitList)
 
template<typename... ArgsType>
UE_FORCEINLINE_HINT SizeType Emplace (ArgsType &&... Args)
 
template<typename... ArgsType>
UE_FORCEINLINE_HINT ElementTypeEmplace_GetRef (ArgsType &&... Args) UE_LIFETIMEBOUND
 
template<typename... ArgsType>
UE_FORCEINLINE_HINT void EmplaceAt (SizeType Index, ArgsType &&... Args)
 
template<typename... ArgsType>
UE_FORCEINLINE_HINT ElementTypeEmplaceAt_GetRef (SizeType Index, ArgsType &&... Args) UE_LIFETIMEBOUND
 
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add (ElementType &&Item)
 
UE_NODEBUG UE_FORCEINLINE_HINT SizeType Add (const ElementType &Item)
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeAdd_GetRef (ElementType &&Item) UE_LIFETIMEBOUND
 
UE_NODEBUG UE_FORCEINLINE_HINT ElementTypeAdd_GetRef (const ElementType &Item) UE_LIFETIMEBOUND
 
SizeType AddZeroed ()
 
SizeType AddZeroed (SizeType Count)
 
ElementTypeAddZeroed_GetRef () UE_LIFETIMEBOUND
 
SizeType AddDefaulted ()
 
SizeType AddDefaulted (SizeType Count)
 
ElementTypeAddDefaulted_GetRef () UE_LIFETIMEBOUND
 
template<typename AliasElementType = ElementType>
 operator TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > & ()
 
template<typename AliasElementType = ElementType>
 operator const TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > & () const
 
template<typename AliasElementType = ElementType>
TArrayoperator= (TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, AllocatorType > &&Other)
 
template<typename OtherAllocator , typename AliasElementType = ElementType>
TArrayoperator= (const TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &Other)
 
template<typename OtherAllocator , typename AliasElementType = ElementType>
SizeType Insert (const TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &Items, const SizeType InIndex)
 
template<typename OtherAllocator , typename AliasElementType = ElementType>
SizeType Insert (TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &&Items, const SizeType InIndex)
 
template<typename AliasElementType = ElementType>
void Append (const typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType *Ptr, SizeType Count)
 
UE_FORCEINLINE_HINT SizeType AddUnique (ElementType &&Item)
 
UE_FORCEINLINE_HINT SizeType AddUnique (const ElementType &Item)
 
UE_FORCEINLINE_HINT void Reserve (SizeType Number)
 
void Init (const ElementType &Element, SizeType Number)
 
SizeType RemoveSingle (const ElementType &Item)
 
SizeType Remove (const ElementType &Item)
 
template<class PREDICATE_CLASS >
SizeType RemoveAll (const PREDICATE_CLASS &Predicate)
 
template<class PREDICATE_CLASS >
SizeType RemoveAllSwap (const PREDICATE_CLASS &Predicate, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT SizeType RemoveAllSwap (const PREDICATE_CLASS &Predicate, bool bAllowShrinking)
 
SizeType RemoveSingleSwap (const ElementType &Item, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT SizeType RemoveSingleSwap (const ElementType &Item, bool bAllowShrinking)
 
SizeType RemoveSwap (const ElementType &Item, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT SizeType RemoveSwap (const ElementType &Item, bool bAllowShrinking)
 
UE_FORCEINLINE_HINT void SwapMemory (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 
UE_FORCEINLINE_HINT void Swap (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 
template<typename SearchType >
bool FindItemByClass (SearchType **Item=nullptr, SizeType *ItemIndex=nullptr, SizeType StartIndex=0) const
 
UE_NODEBUG TIterator CreateIterator ()
 
UE_NODEBUG TConstIterator CreateConstIterator () const
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType begin ()
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForConstIteratorType begin () const
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForIteratorType end ()
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForConstIteratorType end () const
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForReverseIteratorType rbegin ()
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForConstReverseIteratorType rbegin () const
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForReverseIteratorType rend ()
 
UE_NODEBUG UE_FORCEINLINE_HINT RangedForConstReverseIteratorType rend () const
 
UE_NODEBUG void Sort ()
 
template<class PREDICATE_CLASS >
UE_NODEBUG void Sort (const PREDICATE_CLASS &Predicate)
 
UE_NODEBUG void StableSort ()
 
template<class PREDICATE_CLASS >
UE_NODEBUG void StableSort (const PREDICATE_CLASS &Predicate)
 
void WriteMemoryImage (FMemoryImageWriter &Writer) const
 
void CopyUnfrozen (const FMemoryUnfreezeContent &Context, void *Dst) const
 
void ToString (const FPlatformTypeLayoutParameters &LayoutParams, FMemoryToStringContext &OutContext) const
 
template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT void Heapify (const PREDICATE_CLASS &Predicate)
 
UE_NODEBUG void Heapify ()
 
template<class PREDICATE_CLASS >
SizeType HeapPush (ElementType &&InItem, const PREDICATE_CLASS &Predicate)
 
template<class PREDICATE_CLASS >
SizeType HeapPush (const ElementType &InItem, const PREDICATE_CLASS &Predicate)
 
UE_NODEBUG SizeType HeapPush (ElementType &&InItem)
 
UE_NODEBUG SizeType HeapPush (const ElementType &InItem)
 
template<class PREDICATE_CLASS >
void HeapPop (ElementType &OutItem, const PREDICATE_CLASS &Predicate, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT void HeapPop (ElementType &OutItem, const PREDICATE_CLASS &Predicate, bool bAllowShrinking)
 
UE_NODEBUG void HeapPop (ElementType &OutItem, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void HeapPop (ElementType &OutItem, bool bAllowShrinking)
 
template<class PREDICATE_CLASS >
UE_NODEBUG void VerifyHeap (const PREDICATE_CLASS &Predicate)
 
template<class PREDICATE_CLASS >
void HeapPopDiscard (const PREDICATE_CLASS &Predicate, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT void HeapPopDiscard (const PREDICATE_CLASS &Predicate, bool bAllowShrinking)
 
UE_NODEBUG void HeapPopDiscard (EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void HeapPopDiscard (bool bAllowShrinking)
 
UE_NODEBUG const ElementTypeHeapTop () const UE_LIFETIMEBOUND
 
UE_NODEBUG ElementTypeHeapTop () UE_LIFETIMEBOUND
 
template<class PREDICATE_CLASS >
void HeapRemoveAt (SizeType Index, const PREDICATE_CLASS &Predicate, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
template<class PREDICATE_CLASS >
UE_NODEBUG void HeapRemoveAt (SizeType Index, const PREDICATE_CLASS &Predicate, bool bAllowShrinking)
 
UE_NODEBUG void HeapRemoveAt (SizeType Index, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
 
UE_NODEBUG UE_FORCEINLINE_HINT void HeapRemoveAt (SizeType Index, bool bAllowShrinking)
 
template<class PREDICATE_CLASS >
UE_NODEBUG void HeapSort (const PREDICATE_CLASS &Predicate)
 
UE_NODEBUG void HeapSort ()
 
UE_NODEBUG const ElementAllocatorTypeGetAllocatorInstance () const
 
UE_NODEBUG ElementAllocatorTypeGetAllocatorInstance ()
 
template<typename OtherElementType , typename OtherSizeType >
UE_FORCEINLINE_HINT TArray (const TArrayView< OtherElementType, OtherSizeType > &Other)
 
template<typename OtherElementType , typename OtherSizeType >
TArray< InElementType, InAllocatorType > & operator= (const TArrayView< OtherElementType, OtherSizeType > &Other)
 

Static Public Member Functions

UE_NODEBUG static UE_FORCEINLINE_HINT constexpr uint32 GetTypeSize ()
 
static void AppendHash (const FPlatformTypeLayoutParameters &LayoutParams, FSHA1 &Hasher)
 

Static Public Attributes

static constexpr bool bHasIntrusiveUnsetOptionalState = true
 

Protected Attributes

ElementAllocatorType AllocatorInstance
 
SizeType ArrayNum
 
SizeType ArrayMax
 

Friends

template<typename OtherInElementType , typename OtherAllocator >
class TArray
 Array that allocates elements on the heap.
 
template<typename ElementType , typename AllocatorType >
class TIndirectArray
 
struct TArrayPrivateFriend
 

Detailed Description

template<typename InElementType, typename InAllocatorType>
class TArray< InElementType, InAllocatorType >

Templated dynamic array

A dynamically sized array of typed elements. Makes the assumption that your elements are relocate-able; i.e. that they can be transparently moved to new memory without a copy constructor. The main implication is that pointers to elements in the TArray may be invalidated by adding or removing other elements to the array. Removal of elements is O(N) and invalidates the indices of subsequent elements.

Caution: as noted below some methods are not safe for element types that require constructors.

Examples
/work/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

Member Typedef Documentation

◆ AllocatorType

◆ ElementAllocatorType

using TArray< InElementType, InAllocatorType >::ElementAllocatorType = std::conditional_t< AllocatorType::NeedsElementType, typename AllocatorType::template ForElementType<ElementType>, typename AllocatorType::ForAnyElementType >

◆ ElementType

◆ IntrusiveUnsetOptionalStateType

using TArray< InElementType, InAllocatorType >::IntrusiveUnsetOptionalStateType = TArray

◆ RangedForConstIteratorType

◆ RangedForConstReverseIteratorType

◆ RangedForIteratorType

◆ RangedForReverseIteratorType

◆ SizeType

using TArray< InElementType, InAllocatorType >::SizeType = typename InAllocatorType::SizeType

◆ TConstIterator

◆ TIterator

Constructor & Destructor Documentation

◆ TArray() [1/13]

Constructor, initializes element number counters.

◆ TArray() [2/13]

Explicit consteval constructor for allocators that require zero-initialization of members for constant initialization

◆ TArray() [3/13]

Constructor from a raw array of elements.

Parameters
PtrA pointer to an array of elements to copy.
CountThe number of elements to copy from Ptr.
See also
Append

◆ TArray() [4/13]

◆ TArray() [5/13]

TArray< InElementType, InAllocatorType >::TArray ( std::initializer_list< InElementType InitList)
inline

Initializer list constructor

◆ TArray() [6/13]

Copy constructor with changed allocator. Use the common routine to perform the copy.

Parameters
OtherThe source array to copy.

◆ TArray() [7/13]

Copy constructor. Use the common routine to perform the copy.

Parameters
OtherThe source array to copy.

◆ TArray() [8/13]

Copy constructor. Use the common routine to perform the copy.

Parameters
OtherThe source array to copy.
ExtraSlackTells how much extra memory should be preallocated at the end of the array in the number of elements.

◆ TArray() [9/13]

Move constructor.

Parameters
OtherArray to move from.

◆ TArray() [10/13]

Move constructor.

Parameters
OtherArray to move from.

◆ TArray() [11/13]

Move constructor.

Parameters
OtherArray to move from.
ExtraSlackTells how much extra memory should be preallocated at the end of the array in the number of elements.

◆ ~TArray()

◆ TArray() [12/13]

◆ TArray() [13/13]

Member Function Documentation

◆ Add() [1/2]

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
See also
AddDefaulted, AddUnique, AddZeroed, Append, Insert

◆ Add() [2/2]

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

Move semantics version.

Parameters
ItemThe item to add
Returns
Index to the new item
See also
AddDefaulted, AddUnique, AddZeroed, Append, Insert

◆ Add_GetRef() [1/2]

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

Parameters
ItemThe item to add
Returns
A reference to the newly-inserted element.
See also
AddDefaulted_GetRef, AddUnique_GetRef, AddZeroed_GetRef, Insert_GetRef

◆ Add_GetRef() [2/2]

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

Move semantics version.

Parameters
ItemThe item to add
Returns
A reference to the newly-inserted element.
See also
AddDefaulted_GetRef, AddUnique_GetRef, AddZeroed_GetRef, Insert_GetRef

◆ AddDefaulted() [1/2]

Adds new items to the end of the array, possibly reallocating the whole array to fit. The new items will be default-constructed.

Parameters
CountThe number of new items to add.
Returns
Index to the first of the new items.
See also
Add, AddZeroed, AddUnique, Append, Insert

◆ AddDefaulted() [2/2]

◆ AddDefaulted_GetRef()

ElementType & TArray< InElementType, InAllocatorType >::AddDefaulted_GetRef ( )
inline

Add a new item to the end of the array, possibly reallocating the whole array to fit. The new item will be default-constructed.

Returns
A reference to the newly-inserted element.
See also
Add_GetRef, AddZeroed_GetRef, AddUnique_GetRef, Insert_GetRef

◆ AddUninitialized() [1/2]

Adds a given number of uninitialized elements into the array.

Caution, AddUninitialized() will create elements without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Parameters
CountNumber of elements to add.
Returns
Number of elements in array before addition.

◆ AddUninitialized() [2/2]

◆ AddUnique() [1/2]

Adds unique element to array if it doesn't exist.

Parameters
ItemItem to add.
Returns
Index of the element in the array.
See also
Add, AddDefaulted, AddZeroed, Append, Insert

◆ AddUnique() [2/2]

Adds unique element to array if it doesn't exist.

Move semantics version.

Parameters
ItemItem to add.
Returns
Index of the element in the array.
See also
Add, AddDefaulted, AddZeroed, Append, Insert

◆ AddZeroed() [1/2]

Adds new items to the end of the array, possibly reallocating the whole array to fit. The new items will be zeroed.

Caution, AddZeroed() will create elements without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Parameters
CountThe number of new items to add.
Returns
Index to the first of the new items.
See also
Add, AddDefaulted, AddUnique, Append, Insert

◆ AddZeroed() [2/2]

◆ AddZeroed_GetRef()

Adds a new item to the end of the array, possibly reallocating the whole array to fit. The new item will be zeroed.

Caution, AddZeroed_GetRef() will create elements without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Returns
A reference to the newly-inserted element.
See also
Add_GetRef, AddDefaulted_GetRef, AddUnique_GetRef, Insert_GetRef

◆ Append() [1/6]

void TArray< InElementType, InAllocatorType >::Append ( const ElementType Ptr,
SizeType  Count 
)
inline

Adds a raw array of elements to the end of the TArray.

Parameters
PtrA pointer to an array of elements to add.
CountThe number of elements to insert from Ptr.
See also
Add, Insert

◆ Append() [2/6]

Appends the specified array to this array.

AllocatorType changing version.

Parameters
SourceThe array to append.
See also
Add, Insert

◆ Append() [3/6]

template<typename AliasElementType = ElementType>
void TArray< InElementType, InAllocatorType >::Append ( const typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType *  Ptr,
SizeType  Count 
)
inline

Adds a raw array of elements to the end of the TArray. Compatible element type version.

Parameters
PtrA pointer to an array of elements to add.
CountThe number of elements to insert from Ptr.
See also
Add, Insert

◆ Append() [4/6]

template<typename RangeType UE_REQUIRES>
void TArray< InElementType, InAllocatorType >::Append ( RangeType &&  Source)
inline

Appends the elements from a contiguous range to this array.

Parameters
SourceThe range of elements to append.
See also
Add, Insert

◆ Append() [5/6]

UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::Append ( std::initializer_list< ElementType InitList)
inline

Adds an initializer list of elements to the end of the TArray.

Parameters
InitListThe initializer list of elements to add.
See also
Add, Insert

◆ Append() [6/6]

Appends the specified array to this array.

Parameters
SourceThe array to append.
See also
Add, Insert

◆ AppendHash()

static void TArray< InElementType, InAllocatorType >::AppendHash ( const FPlatformTypeLayoutParameters LayoutParams,
FSHA1 Hasher 
)
inlinestatic

◆ begin() [1/2]

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

◆ begin() [2/2]

◆ BulkSerialize()

void TArray< InElementType, InAllocatorType >::BulkSerialize ( FArchive Ar,
bool  bForcePerElementSerialization = false 
)
inline

Bulk serialize array as a single memory blob when loading. Uses regular serialization code for saving and doesn't serialize at all otherwise (e.g. transient, garbage collection, ...).

Requirements:

  • T's << operator needs to serialize ALL member variables in the SAME order they are layed out in memory.
  • T's << operator can NOT perform any fixup operations. This limitation can be lifted by manually copying the code after the BulkSerialize call.
  • T can NOT contain any member variables requiring constructor calls or pointers
  • sizeof(ElementType) must be equal to the sum of sizes of it's member variables.
    • e.g. use pragma pack (push,1)/ (pop) to ensure alignment
    • match up uint8/ WORDs so everything always end up being properly aligned
  • Code can not rely on serialization of T if neither IsLoading() nor IsSaving() is true.
  • Can only be called platforms that either have the same endianness as the one the content was saved with or had the endian conversion occur in a cooking process like e.g. for consoles.

Notes:

  • it is safe to call BulkSerialize on TTransArrays

IMPORTANT:

  • This is Overridden in XeD3dResourceArray.h Please make certain changes are propagated accordingly
Parameters
ArFArchive to bulk serialize this TArray to/from

◆ CheckAddress()

Checks that the specified address is not part of an element within the container. Used for implementations to check that reference arguments aren't going to be invalidated by possible reallocation.

Parameters
AddrThe address to check.
See also
Add, Remove

◆ CheckInvariants()

Checks array invariants: if array size is greater than or equal to zero and less than or equal to the maximum.

◆ Contains()

bool TArray< InElementType, InAllocatorType >::Contains ( const ComparisonType Item) const
inline

Checks if this array contains the element.

Returns
True if found. False otherwise.
See also
ContainsByPredicate, FilterByPredicate, FindByPredicate

◆ ContainsByPredicate()

template<typename Predicate >
UE_NODEBUG UE_FORCEINLINE_HINT bool TArray< InElementType, InAllocatorType >::ContainsByPredicate ( Predicate  Pred) const
inline

Checks if this array contains an element for which the predicate is true.

Parameters
Predicateto use
Returns
True if found. False otherwise.
See also
Contains, Find

◆ CopyUnfrozen()

void TArray< InElementType, InAllocatorType >::CopyUnfrozen ( const FMemoryUnfreezeContent Context,
void Dst 
) const
inline

◆ CountBytes()

Count bytes needed to serialize this array.

Parameters
ArArchive to count for.

◆ CreateConstIterator()

Creates a const iterator for the contents of this array

Returns
The const iterator.

◆ CreateIterator()

Creates an iterator for the contents of this array

Returns
The iterator.

◆ Emplace()

template<typename... ArgsType>
UE_FORCEINLINE_HINT SizeType TArray< InElementType, InAllocatorType >::Emplace ( ArgsType &&...  Args)
inline

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

Parameters
ArgsThe arguments to forward to the constructor of the new item.
Returns
Index to the new item

◆ Emplace_GetRef()

template<typename... ArgsType>
UE_FORCEINLINE_HINT ElementType & TArray< InElementType, InAllocatorType >::Emplace_GetRef ( ArgsType &&...  Args)
inline

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

Parameters
ArgsThe arguments to forward to the constructor of the new item.
Returns
A reference to the newly-inserted element.

◆ EmplaceAt()

template<typename... ArgsType>
UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::EmplaceAt ( SizeType  Index,
ArgsType &&...  Args 
)
inline

Constructs a new item at a specified index, possibly reallocating the whole array to fit.

Parameters
IndexThe index to add the item at.
ArgsThe arguments to forward to the constructor of the new item.

◆ EmplaceAt_GetRef()

template<typename... ArgsType>
UE_FORCEINLINE_HINT ElementType & TArray< InElementType, InAllocatorType >::EmplaceAt_GetRef ( SizeType  Index,
ArgsType &&...  Args 
)
inline

Constructs a new item at a specified index, possibly reallocating the whole array to fit.

Parameters
IndexThe index to add the item at.
ArgsThe arguments to forward to the constructor of the new item.
Returns
A reference to the newly-inserted element.

◆ Empty()

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

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

◆ end() [1/2]

◆ end() [2/2]

◆ FilterByPredicate()

template<typename Predicate >
TArray< ElementType > TArray< InElementType, InAllocatorType >::FilterByPredicate ( Predicate  Pred) const
inline

Filters the elements in the array based on a predicate functor.

Parameters
PredThe functor to apply to each element.
Returns
TArray with the same type as this object which contains the subset of elements for which the functor returns true.
See also
FindByPredicate, ContainsByPredicate

◆ Find() [1/2]

Finds element within the array.

Parameters
ItemItem to look for.
Returns
Index of the found element. INDEX_NONE otherwise.
See also
FindLast, FindLastByPredicate

◆ Find() [2/2]

Finds element within the array.

Parameters
ItemItem to look for.
IndexWill contain the found index.
Returns
True if found. False otherwise.
See also
FindLast, FindLastByPredicate

◆ FindByKey() [1/2]

template<typename KeyType >
ElementType * TArray< InElementType, InAllocatorType >::FindByKey ( const KeyType &  Key)
inline

Finds an item by key (assuming the ElementType overloads operator== for the comparison). Time Complexity: O(n), starts iteration from the beginning so better performance if Key is in the front

Parameters
KeyThe key to search by.
Returns
Pointer to the first matching element, or nullptr if none is found.
See also
Find

◆ FindByKey() [2/2]

template<typename KeyType >
UE_REWRITE const ElementType * TArray< InElementType, InAllocatorType >::FindByKey ( const KeyType &  Key) const
inline

◆ FindByPredicate() [1/2]

template<typename Predicate >
ElementType * TArray< InElementType, InAllocatorType >::FindByPredicate ( Predicate  Pred)
inline

Finds an element which matches a predicate functor.

Parameters
PredThe functor to apply to each element.
Returns
Pointer to the first element for which the predicate returns true, or nullptr if none is found.
See also
FilterByPredicate, ContainsByPredicate

◆ FindByPredicate() [2/2]

template<typename Predicate >
UE_REWRITE const ElementType * TArray< InElementType, InAllocatorType >::FindByPredicate ( Predicate  Pred) const
inline

◆ FindItemByClass()

template<typename SearchType >
bool TArray< InElementType, InAllocatorType >::FindItemByClass ( SearchType **  Item = nullptr,
SizeType ItemIndex = nullptr,
SizeType  StartIndex = 0 
) const
inline

Searches for the first entry of the specified type, will only work with TArray<UObject*>. Optionally return the item's index, and can specify the start index.

Parameters
Item(Optional output) If it's not null, then it will point to the found element. Untouched if element hasn't been found.
ItemIndex(Optional output) If it's not null, then it will be set to the position of found element in the array. Untouched if element hasn't been found.
StartIndex(Optional) Index in array at which the function should start to look for element.
Returns
True if element was found. False otherwise.

◆ FindLast() [1/2]

SizeType TArray< InElementType, InAllocatorType >::FindLast ( const ElementType Item) const
inline

Finds element within the array starting from the end.

Parameters
ItemItem to look for.
Returns
Index of the found element. INDEX_NONE otherwise.

◆ FindLast() [2/2]

Finds element within the array starting from the end.

Parameters
ItemItem to look for.
IndexOutput parameter. Found index.
Returns
True if found. False otherwise.
See also
Find, FindLastByPredicate

◆ FindLastByPredicate() [1/2]

template<typename Predicate >
UE_NODEBUG UE_FORCEINLINE_HINT SizeType TArray< InElementType, InAllocatorType >::FindLastByPredicate ( Predicate  Pred) const
inline

Searches the array for the last occurrence of an element which matches the specified predicate.

Parameters
PredPredicate taking array element and returns true if element matches search criteria, false otherwise.
Returns
Index of the found element. INDEX_NONE otherwise.

◆ FindLastByPredicate() [2/2]

template<typename Predicate >
SizeType TArray< InElementType, InAllocatorType >::FindLastByPredicate ( Predicate  Pred,
SizeType  Count 
) const
inline

Searches an initial subrange of the array for the last occurrence of an element which matches the specified predicate.

Parameters
PredPredicate taking array element and returns true if element matches search criteria, false otherwise.
CountThe number of elements from the front of the array through which to search.
Returns
Index of the found element. INDEX_NONE otherwise.

◆ GetAllocatedSize()

Helper function to return the amount of memory allocated by this container. Only returns the size of allocations made directly by the container, not the elements themselves.

Returns
Number of bytes allocated by this container.

◆ GetAllocatorInstance() [1/2]

◆ GetAllocatorInstance() [2/2]

UE_NODEBUG const ElementAllocatorType & TArray< InElementType, InAllocatorType >::GetAllocatorInstance ( ) const
inline

◆ GetData() [1/2]

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

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

◆ GetData() [2/2]

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

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

◆ GetSlack()

Returns the amount of slack in this array in elements.

See also
Num, Shrink

◆ GetTypeSize()

Helper function returning the size of the inner type.

Returns
Size in bytes of array type.

◆ Heapify() [1/2]

Builds an implicit heap from the array. Assumes < operator is defined for the template type.

Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ Heapify() [2/2]

Implicit heaps Builds an implicit heap from the array.

Parameters
PredicatePredicate class instance.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPop() [1/4]

◆ HeapPop() [2/4]

template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::HeapPop ( ElementType OutItem,
const PREDICATE_CLASS Predicate,
bool  bAllowShrinking 
)
inline

◆ HeapPop() [3/4]

Removes the top element from the heap.

Parameters
OutItemThe removed item.
PredicatePredicate class instance.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPop() [4/4]

Removes the top element from the heap. Assumes < operator is defined for the template type.

Parameters
OutItemThe removed item.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPopDiscard() [1/4]

◆ HeapPopDiscard() [2/4]

template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::HeapPopDiscard ( const PREDICATE_CLASS Predicate,
bool  bAllowShrinking 
)
inline

◆ HeapPopDiscard() [3/4]

Removes the top element from the heap.

Parameters
PredicatePredicate class instance.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPopDiscard() [4/4]

Removes the top element from the heap. Assumes < operator is defined for the template type.

Parameters
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPush() [1/4]

Adds a new element to the heap. Assumes < operator is defined for the template type.

Parameters
InItemItem to be added.
Returns
The index of the new element.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPush() [2/4]

template<class PREDICATE_CLASS >
SizeType TArray< InElementType, InAllocatorType >::HeapPush ( const ElementType InItem,
const PREDICATE_CLASS Predicate 
)
inline

Adds a new element to the heap.

Parameters
InItemItem to be added.
PredicatePredicate class instance.
Returns
The index of the new element.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPush() [3/4]

Adds a new element to the heap. Assumes < operator is defined for the template type.

Parameters
InItemItem to be added.
Returns
The index of the new element.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPush() [4/4]

template<class PREDICATE_CLASS >
SizeType TArray< InElementType, InAllocatorType >::HeapPush ( ElementType &&  InItem,
const PREDICATE_CLASS Predicate 
)
inline

Adds a new element to the heap.

Parameters
InItemItem to be added.
PredicatePredicate class instance.
Returns
The index of the new element.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapRemoveAt() [1/4]

UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::HeapRemoveAt ( SizeType  Index,
bool  bAllowShrinking 
)
inline

◆ HeapRemoveAt() [2/4]

template<class PREDICATE_CLASS >
UE_NODEBUG void TArray< InElementType, InAllocatorType >::HeapRemoveAt ( SizeType  Index,
const PREDICATE_CLASS Predicate,
bool  bAllowShrinking 
)
inline

◆ HeapRemoveAt() [3/4]

template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocatorType >::HeapRemoveAt ( SizeType  Index,
const PREDICATE_CLASS Predicate,
EAllowShrinking  AllowShrinking = UE::Core::Private::AllowShrinkingByDefault<AllocatorType>() 
)
inline

Removes an element from the heap.

Parameters
IndexPosition at which to remove item.
PredicatePredicate class instance.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapRemoveAt() [4/4]

Removes an element from the heap. Assumes < operator is defined for the template type.

Parameters
IndexPosition at which to remove item.
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapSort() [1/2]

Performs heap sort on the array. Assumes < operator is defined for the template type.

Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapSort() [2/2]

template<class PREDICATE_CLASS >
UE_NODEBUG void TArray< InElementType, InAllocatorType >::HeapSort ( const PREDICATE_CLASS Predicate)
inline

Performs heap sort on the array.

Parameters
PredicatePredicate class instance.
Note
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapTop() [1/2]

Returns the top element from the heap (does not remove the element).

Const version.

Returns
The reference to the top element from the heap.

◆ HeapTop() [2/2]

Returns the top element from the heap (does not remove the element).

Returns
The reference to the top element from the heap.

◆ IndexOfByKey()

template<typename KeyType >
SizeType TArray< InElementType, InAllocatorType >::IndexOfByKey ( const KeyType &  Key) const
inline

Finds an item by key (assuming the ElementType overloads operator== for the comparison).

Parameters
KeyThe key to search by.
Returns
Index to the first matching element, or INDEX_NONE if none is found.

◆ IndexOfByPredicate()

template<typename Predicate >
SizeType TArray< InElementType, InAllocatorType >::IndexOfByPredicate ( Predicate  Pred) const
inline

Finds an item by predicate.

Parameters
PredThe predicate to match.
Returns
Index to the first matching element, or INDEX_NONE if none is found.

◆ Init()

void TArray< InElementType, InAllocatorType >::Init ( const ElementType Element,
SizeType  Number 
)
inline

Sets the size of the array, filling it with the given element.

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

◆ Insert() [1/8]

SizeType TArray< InElementType, InAllocatorType >::Insert ( const ElementType Item,
SizeType  Index 
)
inline

Inserts a given element into the array at given location.

Parameters
ItemThe element to insert.
IndexTells where to insert the new elements.
Returns
Location at which the insert was done.
See also
Add, Remove

◆ Insert() [2/8]

SizeType TArray< InElementType, InAllocatorType >::Insert ( const ElementType Ptr,
SizeType  Count,
SizeType  Index 
)
inline

Inserts a raw array of elements at a particular index in the TArray.

Parameters
PtrA pointer to an array of elements to add.
CountThe number of elements to insert from Ptr.
IndexThe index to insert the elements at.
Returns
The index of the first element inserted.
See also
Add, Remove

◆ Insert() [3/8]

SizeType TArray< InElementType, InAllocatorType >::Insert ( const TArray< ElementType, OtherAllocator > &  Items,
const SizeType  InIndex 
)
inline

Inserts given elements into the array at given location.

Parameters
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
Returns
Location at which the item was inserted.

◆ Insert() [4/8]

template<typename OtherAllocator , typename AliasElementType = ElementType>
SizeType TArray< InElementType, InAllocatorType >::Insert ( const TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &  Items,
const SizeType  InIndex 
)
inline

Inserts given elements into the array at given location. Compatible element type version.

Parameters
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
Returns
Location at which the item was inserted.

◆ Insert() [5/8]

Inserts a given element into the array at given location. Move semantics version.

Parameters
ItemThe element to insert.
IndexTells where to insert the new elements.
Returns
Location at which the insert was done.
See also
Add, Remove

◆ Insert() [6/8]

SizeType TArray< InElementType, InAllocatorType >::Insert ( std::initializer_list< ElementType InitList,
const SizeType  InIndex 
)
inline

Inserts given elements into the array at given location.

Parameters
InitListArray of elements to insert.
InIndexTells where to insert the new elements.
Returns
Location at which the item was inserted.

◆ Insert() [7/8]

Inserts given elements into the array at given location.

Parameters
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
Returns
Location at which the item was inserted.

◆ Insert() [8/8]

Inserts given elements into the array at given location. Compatible element type version.

Parameters
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
Returns
Location at which the item was inserted.

◆ Insert_GetRef() [1/2]

ElementType & TArray< InElementType, InAllocatorType >::Insert_GetRef ( const ElementType Item,
SizeType  Index 
)
inline

Inserts a given element into the array at given location.

Parameters
ItemThe element to insert.
IndexTells where to insert the new element.
Returns
A reference to the newly-inserted element.
See also
Add, Remove

◆ Insert_GetRef() [2/2]

ElementType & TArray< InElementType, InAllocatorType >::Insert_GetRef ( ElementType &&  Item,
SizeType  Index 
)
inline

Inserts a given element into the array at given location. Move semantics version.

Parameters
ItemThe element to insert.
IndexTells where to insert the new element.
Returns
A reference to the newly-inserted element.
See also
Add, Remove

◆ InsertDefaulted() [1/2]

void TArray< InElementType, InAllocatorType >::InsertDefaulted ( SizeType  Index)
inline

Inserts a given number of default-constructed elements into the array at a given location.

Parameters
IndexTells where to insert the new elements.
CountNumber of elements to add.
See also
Insert, InsertUninitialized, InsertZeroed

◆ InsertDefaulted() [2/2]

void TArray< InElementType, InAllocatorType >::InsertDefaulted ( SizeType  Index,
SizeType  Count 
)
inline

◆ InsertDefaulted_GetRef()

ElementType & TArray< InElementType, InAllocatorType >::InsertDefaulted_GetRef ( SizeType  Index)
inline

Inserts a default-constructed element into the array at a given location.

Parameters
IndexTells where to insert the new element.
Returns
A reference to the newly-inserted element.
See also
Insert_GetRef, InsertZeroed_GetRef

◆ InsertUninitialized() [1/2]

Inserts a given number of uninitialized elements into the array at given location.

Caution, InsertUninitialized() will create elements without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Parameters
IndexTells where to insert the new elements.
CountNumber of elements to add.
See also
Insert, InsertZeroed, InsertDefaulted

◆ InsertUninitialized() [2/2]

◆ InsertZeroed() [1/2]

Inserts a given number of zeroed elements into the array at given location.

Caution, InsertZeroed() will create elements without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Parameters
IndexTells where to insert the new elements.
CountNumber of elements to add.
See also
Insert, InsertUninitialized, InsertDefaulted

◆ InsertZeroed() [2/2]

void TArray< InElementType, InAllocatorType >::InsertZeroed ( SizeType  Index,
SizeType  Count 
)
inline

◆ InsertZeroed_GetRef()

ElementType & TArray< InElementType, InAllocatorType >::InsertZeroed_GetRef ( SizeType  Index)
inline

Inserts a zeroed element into the array at given location.

Caution, InsertZeroed_GetRef() will create an element without calling the constructor and this is not appropriate for element types that require a constructor to function properly.

Parameters
IndexTells where to insert the new element.
Returns
A reference to the newly-inserted element.
See also
Insert_GetRef, InsertDefaulted_GetRef

◆ IsEmpty()

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

Returns
True if the array is empty.
See also
Num

◆ IsValidIndex()

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

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

◆ Last() [1/2]

UE_REWRITE const ElementType & TArray< InElementType, InAllocatorType >::Last ( SizeType  IndexFromTheEnd = 0) const
inline

◆ Last() [2/2]

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.

◆ Max()

Returns maximum number of elements in array.

Returns
Maximum number of elements in array.
See also
GetSlack

◆ Num()

Returns number of elements in array.

Returns
Number of elements in array.
See also
GetSlack

◆ NumBytes()

Returns
Number of bytes used, excluding slack

◆ operator const TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > &()

Immutable implicit conversion operator to constant container of compatible element type.

◆ operator TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > &()

Mutable implicit conversion operator to container of compatible element type.

◆ operator!=()

Inequality operator.

Parameters
OtherArrayArray to compare.
Returns
True if this array is NOT the same as OtherArray. False otherwise.

◆ operator+=() [1/3]

Appends the specified array to this array. Cannot append to self.

Parameters
OtherThe array to append.

◆ operator+=() [2/3]

UE_NODEBUG TArray & TArray< InElementType, InAllocatorType >::operator+= ( std::initializer_list< ElementType InitList)
inline

Appends the specified initializer list to this array.

Parameters
InitListThe initializer list to append.

◆ operator+=() [3/3]

Appends the specified array to this array. Cannot append to self.

Move semantics version.

Parameters
OtherThe array to append.

◆ operator=() [1/8]

Assignment operator. First deletes all currently contained elements and then copies from other array.

Parameters
OtherThe source array to assign from.

◆ operator=() [2/8]

Assignment operator. First deletes all currently contained elements and then copies from other array.

AllocatorType changing version.

Parameters
OtherThe source array to assign from.

◆ operator=() [3/8]

Assignment operator. First deletes all currently contained elements and then copies from other array. Compatible element type version.

Parameters
OtherThe source array to assign from.

◆ operator=() [4/8]

◆ operator=() [5/8]

◆ operator=() [6/8]

TArray & TArray< InElementType, InAllocatorType >::operator= ( std::initializer_list< InElementType InitList)
inline

Initializer list assignment operator. First deletes all currently contained elements and then copies from initializer list.

Parameters
InitListThe initializer_list to copy from.

◆ operator=() [7/8]

Move assignment operator.

Parameters
OtherArray to assign and move from.

◆ operator=() [8/8]

Move assignment operator. Compatible element type version.

Parameters
OtherArray to assign and move from.

◆ operator==() [1/2]

Equality operator.

Parameters
OtherArrayArray to compare.
Returns
True if this array is the same as OtherArray. False otherwise.

◆ operator==() [2/2]

◆ operator[]() [1/2]

UE_REWRITE const ElementType & TArray< InElementType, InAllocatorType >::operator[] ( SizeType  Index) const
inline

Array bracket operator. Returns reference to element at given index.

Const version of the above.

Returns
Reference to indexed element.

◆ operator[]() [2/2]

Array bracket operator. Returns reference to element at given index.

Returns
Reference to indexed element.

◆ Pop() [1/2]

◆ Pop() [2/2]

Pops element from the array.

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

◆ Push() [1/2]

Pushes element into the array.

Const ref version of the above.

Parameters
ItemItem to push.
See also
Pop, Top

◆ Push() [2/2]

Pushes element into the array.

Parameters
ItemItem to push.

◆ RangeCheck() [1/2]

Checks if index is in array range.

Parameters
IndexIndex to check.

◆ RangeCheck() [2/2]

Checks if a range of indices are in the array range.

Parameters
IndexIndex of the start of the range to check.
CountNumber of elements in the range.

◆ rbegin() [1/2]

◆ rbegin() [2/2]

◆ Remove()

Removes as many instances of Item as there are in the array, maintaining order but not indices.

Parameters
ItemItem to remove from array.
Returns
Number of removed elements.
See also
Add, Insert, RemoveAll, RemoveAllSwap, RemoveSingle, RemoveSwap

◆ RemoveAll()

template<class PREDICATE_CLASS >
SizeType TArray< InElementType, InAllocatorType >::RemoveAll ( const PREDICATE_CLASS Predicate)
inline

Remove all instances that match the predicate, maintaining order but not indices Optimized to work with runs of matches/non-matches

Parameters
PredicatePredicate class instance
Returns
Number of removed elements.
See also
Add, Insert, RemoveAllSwap, RemoveSingle, RemoveSwap

◆ RemoveAllSwap() [1/2]

template<class PREDICATE_CLASS >
UE_NODEBUG UE_FORCEINLINE_HINT SizeType TArray< InElementType, InAllocatorType >::RemoveAllSwap ( const PREDICATE_CLASS Predicate,
bool  bAllowShrinking 
)
inline

◆ RemoveAllSwap() [2/2]

Remove all instances that match the predicate

Parameters
PredicatePredicate class instance
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
See also
Remove, RemoveSingle, RemoveSingleSwap, RemoveSwap

◆ RemoveAt() [1/3]

template<typename CountType >
UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::RemoveAt ( SizeType  Index,
CountType  Count,
bool  bAllowShrinking 
)
inline

◆ RemoveAt() [2/3]

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

◆ RemoveAt() [3/3]

Removes an element at the 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.

◆ RemoveAtSwap() [1/3]

template<typename CountType >
UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::RemoveAtSwap ( SizeType  Index,
CountType  Count,
bool  bAllowShrinking 
)
inline

◆ RemoveAtSwap() [2/3]

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

◆ RemoveAtSwap() [3/3]

Removes an element at the 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.

◆ RemoveSingle()

SizeType TArray< InElementType, InAllocatorType >::RemoveSingle ( const ElementType Item)
inline

Removes the first occurrence of the specified item in the array, maintaining order but not indices.

Parameters
ItemThe item to remove.
Returns
The number of items removed. For RemoveSingleItem, this is always either 0 or 1.
See also
Add, Insert, Remove, RemoveAll, RemoveAllSwap

◆ RemoveSingleSwap() [1/2]

UE_NODEBUG UE_FORCEINLINE_HINT SizeType TArray< InElementType, InAllocatorType >::RemoveSingleSwap ( const ElementType Item,
bool  bAllowShrinking 
)
inline

◆ RemoveSingleSwap() [2/2]

Removes the first occurrence of the specified item in the array. This version is much more efficient O(Count) instead of O(ArrayNum), but does not preserve the order

Parameters
ItemThe item to remove
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Returns
The number of items removed. For RemoveSingleItem, this is always either 0 or 1.
See also
Add, Insert, Remove, RemoveAll, RemoveAllSwap, RemoveSwap

◆ RemoveSwap() [1/2]

UE_NODEBUG UE_FORCEINLINE_HINT SizeType TArray< InElementType, InAllocatorType >::RemoveSwap ( const ElementType Item,
bool  bAllowShrinking 
)
inline

◆ RemoveSwap() [2/2]

Removes all instances of a given item from the array.

This version is much more efficient, because it uses RemoveAtSwap internally which is O(Count) instead of RemoveAt which is O(ArrayNum), but does not preserve the order.

Parameters
ItemThe item to remove
AllowShrinking(Optional) By default, arrays with large amounts of slack will automatically shrink. Use FNonshrinkingAllocator or pass EAllowShrinking::No to prevent this.
Returns
Number of elements removed.
See also
Add, Insert, Remove, RemoveAll, RemoveAllSwap

◆ rend() [1/2]

◆ rend() [2/2]

◆ Reserve()

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.
See also
Shrink

◆ Reset()

Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array. It calls the destructors on held items if needed and then zeros the ArrayNum.

Parameters
NewSizeThe expected usage size after calling this function.

◆ SetNum() [1/2]

◆ SetNum() [2/2]

Resizes array to given number of elements.

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

◆ SetNumUninitialized() [1/2]

UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::SetNumUninitialized ( SizeType  NewNum,
bool  bAllowShrinking 
)
inline

◆ SetNumUninitialized() [2/2]

Resizes array to given number of elements. New elements will be uninitialized.

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

◆ SetNumUnsafeInternal()

void TArray< InElementType, InAllocatorType >::SetNumUnsafeInternal ( SizeType  NewNum)
inline

Does nothing except setting the new number of elements in the array. Does not destruct items, does not de-allocate memory.

Parameters
NewNumNew number of elements in the array, must be <= the current number of elements in the array.

◆ SetNumZeroed() [1/2]

UE_NODEBUG UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::SetNumZeroed ( SizeType  NewNum,
bool  bAllowShrinking 
)
inline

◆ SetNumZeroed() [2/2]

Resizes array to given number of elements, optionally shrinking it. New elements will be zeroed.

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

◆ Shrink()

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

See also
Slack

◆ Sort() [1/2]

Sorts the array assuming < operator is defined for the item type.

Note
: If your array contains raw pointers, they will be automatically dereferenced during sorting. Therefore, your array will be sorted by the values being pointed to, rather than the pointers' values. If this is not desirable, please use Algo::Sort(MyArray) directly instead. The auto-dereferencing behavior does not occur with smart pointers.

◆ Sort() [2/2]

template<class PREDICATE_CLASS >
UE_NODEBUG void TArray< InElementType, InAllocatorType >::Sort ( const PREDICATE_CLASS Predicate)
inline

Sorts the array using user define predicate class.

Parameters
PredicatePredicate class instance.
Note
: If your array contains raw pointers, they will be automatically dereferenced during sorting. Therefore, your predicate will be passed references rather than pointers. If this is not desirable, please use Algo::Sort(MyArray, Predicate) directly instead. The auto-dereferencing behavior does not occur with smart pointers.

◆ StableSort() [1/2]

Stable sorts the array assuming < operator is defined for the item type.

Stable sort is slower than non-stable algorithm.

Note
: If your array contains raw pointers, they will be automatically dereferenced during sorting. Therefore, your array will be sorted by the values being pointed to, rather than the pointers' values. If this is not desirable, please use Algo::StableSort(MyArray) directly instead. The auto-dereferencing behavior does not occur with smart pointers.

◆ StableSort() [2/2]

template<class PREDICATE_CLASS >
UE_NODEBUG void TArray< InElementType, InAllocatorType >::StableSort ( const PREDICATE_CLASS Predicate)
inline

Stable sorts the array using user defined predicate class.

Stable sort is slower than non-stable algorithm.

Parameters
PredicatePredicate class instance
Note
: If your array contains raw pointers, they will be automatically dereferenced during sorting. Therefore, your predicate will be passed references rather than pointers. If this is not desirable, please use Algo::StableSort(MyArray, Predicate) directly instead. The auto-dereferencing behavior does not occur with smart pointers.

◆ Swap()

UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::Swap ( SizeType  FirstIndexToSwap,
SizeType  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.

◆ SwapMemory()

UE_FORCEINLINE_HINT void TArray< InElementType, InAllocatorType >::SwapMemory ( SizeType  FirstIndexToSwap,
SizeType  SecondIndexToSwap 
)
inline

Element-wise array memory swap.

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

◆ Top() [1/2]

◆ Top() [2/2]

Returns the top element, i.e. the last one.

Returns
Reference to the top element.
See also
Pop, Push

◆ ToString()

void TArray< InElementType, InAllocatorType >::ToString ( const FPlatformTypeLayoutParameters LayoutParams,
FMemoryToStringContext OutContext 
) const
inline

◆ VerifyHeap()

template<class PREDICATE_CLASS >
UE_NODEBUG void TArray< InElementType, InAllocatorType >::VerifyHeap ( const PREDICATE_CLASS Predicate)
inline

Verifies the heap.

Parameters
PredicatePredicate class instance.

◆ WriteMemoryImage()

void TArray< InElementType, InAllocatorType >::WriteMemoryImage ( FMemoryImageWriter Writer) const
inline

Friends And Related Symbol Documentation

◆ TArray

Array that allocates elements on the heap.

◆ TArrayPrivateFriend

◆ TIndirectArray

Member Data Documentation

◆ AllocatorInstance

◆ ArrayMax

◆ ArrayNum

◆ bHasIntrusiveUnsetOptionalState

constexpr bool TArray< InElementType, InAllocatorType >::bHasIntrusiveUnsetOptionalState = true
staticconstexpr

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