Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
TArray< InElementType, InAllocatorType > Class Template Reference

#include <Array.h>

+ Collaboration diagram for TArray< InElementType, InAllocatorType >:

Public Types

typedef InAllocatorType::SizeType SizeType
 
typedef InElementType ElementType
 
typedef InAllocatorType AllocatorType
 
typedef InAllocatorType Allocator
 
typedef TChooseClass< AllocatorType::NeedsElementType, typenameAllocatorType::templateForElementType< ElementType >, typenameAllocatorType::ForAnyElementType >::Result ElementAllocatorType
 
typedef TIndexedContainerIterator< TArray, ElementType, SizeTypeTIterator
 
typedef TIndexedContainerIterator< const TArray, const ElementType, SizeTypeTConstIterator
 
typedef TCheckedPointerIterator< ElementType, SizeTypeRangedForIteratorType
 
typedef TCheckedPointerIterator< const ElementType, SizeTypeRangedForConstIteratorType
 

Public Member Functions

FORCEINLINE TArray ()
 
FORCEINLINE 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 , std::enable_if_t< UE4Array_Private::TArrayElementsAreCompatible< ElementType, const OtherElementType & >::Value > * = nullptr>
FORCEINLINE TArray (const TArray< OtherElementType, OtherAllocator > &Other)
 
FORCEINLINE TArray (const TArray &Other)
 
FORCEINLINE 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)
 
FORCEINLINE TArray (TArray &&Other)
 
template<typename OtherElementType , typename OtherAllocator , std::enable_if_t< UE4Array_Private::TArrayElementsAreCompatible< ElementType, OtherElementType && >::Value > * = nullptr>
FORCEINLINE TArray (TArray< OtherElementType, OtherAllocator > &&Other)
 
template<typename OtherElementType , std::enable_if_t< UE4Array_Private::TArrayElementsAreCompatible< ElementType, OtherElementType && >::Value > * = nullptr>
 TArray (TArray< OtherElementType, AllocatorType > &&Other, SizeType ExtraSlack)
 
TArrayoperator= (TArray &&Other)
 
 ~TArray ()
 
FORCEINLINE ElementTypeGetData () UE_LIFETIMEBOUND
 
FORCEINLINE const ElementTypeGetData () const UE_LIFETIMEBOUND
 
FORCEINLINE SIZE_T GetAllocatedSize (void) const
 
FORCEINLINE SizeType GetSlack () const
 
FORCEINLINE void CheckInvariants () const
 
FORCEINLINE void RangeCheck (SizeType Index) const
 
FORCEINLINE bool IsValidIndex (SizeType Index) const
 
bool IsEmpty () const
 
FORCEINLINE SizeType Num () const
 
FORCEINLINE SizeType Max () const
 
FORCEINLINE ElementTypeoperator[] (SizeType Index) UE_LIFETIMEBOUND
 
FORCEINLINE const ElementTypeoperator[] (SizeType Index) const UE_LIFETIMEBOUND
 
template<typename ET = InElementType>
FORCEINLINE TEnableIf<!TIsAbstract< ET >::Value, ElementType >::Type Pop (bool bAllowShrinking=true)
 
FORCEINLINE void Push (ElementType &&Item)
 
FORCEINLINE void Push (const ElementType &Item)
 
FORCEINLINE ElementTypeTop ()
 
FORCEINLINE const ElementTypeTop () const
 
FORCEINLINE ElementTypeLast (SizeType IndexFromTheEnd=0)
 
FORCEINLINE const ElementTypeLast (SizeType IndexFromTheEnd=0) const
 
FORCEINLINE void Shrink ()
 
FORCEINLINE bool Find (const ElementType &Item, SizeType &Index) const
 
SizeType Find (const ElementType &Item) const
 
FORCEINLINE 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 >
FORCEINLINE 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 >
FORCEINLINE const ElementTypeFindByKey (const KeyType &Key) const
 
template<typename KeyType >
ElementTypeFindByKey (const KeyType &Key)
 
template<typename Predicate >
FORCEINLINE const ElementTypeFindByPredicate (Predicate Pred) const
 
template<typename Predicate >
ElementTypeFindByPredicate (Predicate Pred)
 
template<typename Predicate >
TArray< ElementTypeFilterByPredicate (Predicate Pred) const
 
template<typename ComparisonType >
bool Contains (const ComparisonType &Item) const
 
template<typename Predicate >
FORCEINLINE bool ContainsByPredicate (Predicate Pred) const
 
bool operator== (const TArray &OtherArray) const
 
FORCEINLINE bool operator!= (const TArray &OtherArray) const
 
void CountBytes (FArchive &Ar) const
 
FORCEINLINE SizeType AddUninitialized ()
 
FORCEINLINE SizeType AddUninitialized (SizeType Count)
 
FORCEINLINE void InsertUninitialized (SizeType Index)
 
FORCEINLINE void InsertUninitialized (SizeType Index, SizeType Count)
 
void InsertZeroed (SizeType Index)
 
void InsertZeroed (SizeType Index, SizeType Count)
 
ElementTypeInsertZeroed_GetRef (SizeType Index)
 
void InsertDefaulted (SizeType Index)
 
void InsertDefaulted (SizeType Index, SizeType Count)
 
ElementTypeInsertDefaulted_GetRef (SizeType Index)
 
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)
 
FORCEINLINE 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)
 
ElementTypeInsert_GetRef (const ElementType &Item, SizeType Index)
 
FORCEINLINE void RemoveAt (SizeType Index)
 
template<typename CountType >
FORCEINLINE void RemoveAt (SizeType Index, CountType Count, bool bAllowShrinking=true)
 
FORCEINLINE void RemoveAtSwap (SizeType Index)
 
template<typename CountType >
FORCEINLINE void RemoveAtSwap (SizeType Index, CountType Count, bool bAllowShrinking=true)
 
void Reset (SizeType NewSize=0)
 
void Empty (SizeType Slack=0)
 
void SetNum (SizeType NewNum, bool bAllowShrinking=true)
 
void SetNumZeroed (SizeType NewNum, bool bAllowShrinking=true)
 
void SetNumUninitialized (SizeType NewNum, bool bAllowShrinking=true)
 
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 , typename RangeValueType = std::remove_reference_t<RangeType>, typename RangeElementType = TElementType_T<RangeValueType>, std::enable_if_t< TAnd< TIsContiguousContainer< RangeValueType >, TNot< UE4Array_Private::TIsTArrayOrDerivedFromTArray< RangeValueType > >, UE4Array_Private::TTypeIsCompatibleWithRangeElementType< ElementType, RangeType > >::Value > * = nullptr>
void Append (RangeType &&Source)
 
void Append (const ElementType *Ptr, SizeType Count)
 
FORCEINLINE void Append (std::initializer_list< ElementType > InitList)
 
TArrayoperator+= (TArray &&Other)
 
TArrayoperator+= (const TArray &Other)
 
TArrayoperator+= (std::initializer_list< ElementType > InitList)
 
template<typename... ArgsType>
FORCEINLINE SizeType Emplace (ArgsType &&... Args)
 
template<typename... ArgsType>
FORCEINLINE ElementTypeEmplace_GetRef (ArgsType &&... Args)
 
template<typename... ArgsType>
FORCEINLINE void EmplaceAt (SizeType Index, ArgsType &&... Args)
 
template<typename... ArgsType>
FORCEINLINE ElementTypeEmplaceAt_GetRef (SizeType Index, ArgsType &&... Args)
 
FORCEINLINE SizeType Add (ElementType &&Item)
 
FORCEINLINE SizeType Add (const ElementType &Item)
 
FORCEINLINE ElementTypeAdd_GetRef (ElementType &&Item)
 
FORCEINLINE ElementTypeAdd_GetRef (const ElementType &Item)
 
SizeType AddZeroed ()
 
SizeType AddZeroed (SizeType Count)
 
ElementTypeAddZeroed_GetRef ()
 
SizeType AddDefaulted ()
 
SizeType AddDefaulted (SizeType Count)
 
ElementTypeAddDefaulted_GetRef ()
 
template<typename AliasElementType = ElementType, std::enable_if_t< TIsContainerElementTypeReinterpretable< AliasElementType >::Value > * = nullptr>
 operator TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > & ()
 
template<typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeReinterpretable< AliasElementType >::Value > * = nullptr>
 operator const TArray< typename TContainerElementTypeCompatibility< AliasElementType >::ReinterpretType, AllocatorType > & () const
 
template<typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeCopyable< AliasElementType >::Value > * = nullptr>
TArrayoperator= (TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, AllocatorType > &&Other)
 
template<typename OtherAllocator , typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeCopyable< AliasElementType >::Value > * = nullptr>
TArrayoperator= (const TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &Other)
 
template<typename OtherAllocator , typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeCopyable< AliasElementType >::Value > * = nullptr>
SizeType Insert (const TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &Items, const SizeType InIndex)
 
template<typename OtherAllocator , typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeCopyable< AliasElementType >::Value > * = nullptr>
SizeType Insert (TArray< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherAllocator > &&Items, const SizeType InIndex)
 
template<typename AliasElementType = ElementType, typename std::enable_if_t< TIsContainerElementTypeCopyable< AliasElementType >::Value > * = nullptr>
void Append (const typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType *Ptr, SizeType Count)
 
FORCEINLINE SizeType AddUnique (ElementType &&Item)
 
FORCEINLINE SizeType AddUnique (const ElementType &Item)
 
FORCEINLINE 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, bool bAllowShrinking=true)
 
SizeType RemoveSingleSwap (const ElementType &Item, bool bAllowShrinking=true)
 
SizeType RemoveSwap (const ElementType &Item, bool bAllowShrinking=true)
 
FORCEINLINE void SwapMemory (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 
FORCEINLINE void Swap (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 
template<typename SearchType >
bool FindItemByClass (SearchType **Item=nullptr, SizeType *ItemIndex=nullptr, SizeType StartIndex=0) const
 
TIterator CreateIterator ()
 
TConstIterator CreateConstIterator () const
 
FORCEINLINE RangedForIteratorType begin ()
 
FORCEINLINE RangedForConstIteratorType begin () const
 
FORCEINLINE RangedForIteratorType end ()
 
FORCEINLINE RangedForConstIteratorType end () const
 
void Sort ()
 
template<class PREDICATE_CLASS >
void Sort (const PREDICATE_CLASS &Predicate)
 
void StableSort ()
 
template<class PREDICATE_CLASS >
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 >
FORCEINLINE void Heapify (const PREDICATE_CLASS &Predicate)
 
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)
 
SizeType HeapPush (ElementType &&InItem)
 
SizeType HeapPush (const ElementType &InItem)
 
template<class PREDICATE_CLASS >
void HeapPop (ElementType &OutItem, const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 
void HeapPop (ElementType &OutItem, bool bAllowShrinking=true)
 
template<class PREDICATE_CLASS >
void VerifyHeap (const PREDICATE_CLASS &Predicate)
 
template<class PREDICATE_CLASS >
void HeapPopDiscard (const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 
void HeapPopDiscard (bool bAllowShrinking=true)
 
const ElementTypeHeapTop () const
 
ElementTypeHeapTop ()
 
template<class PREDICATE_CLASS >
void HeapRemoveAt (SizeType Index, const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 
void HeapRemoveAt (SizeType Index, bool bAllowShrinking=true)
 
template<class PREDICATE_CLASS >
void HeapSort (const PREDICATE_CLASS &Predicate)
 
void HeapSort ()
 
const ElementAllocatorTypeGetAllocatorInstance () const
 
ElementAllocatorTypeGetAllocatorInstance ()
 
template<typename OtherElementType , typename OtherSizeType >
FORCEINLINE TArray (const TArrayView< OtherElementType, OtherSizeType > &Other)
 
template<typename OtherElementType , typename OtherSizeType >
FORCEINLINE TArray< InElementType, InAllocatorType > & operator= (const TArrayView< OtherElementType, OtherSizeType > &Other)
 

Static Public Member Functions

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

Protected Attributes

ElementAllocatorType AllocatorInstance
 
SizeType ArrayNum
 
SizeType ArrayMax
 

Private Types

using USizeType = typename TMakeUnsigned<SizeType>::Type
 

Private Member Functions

void InsertUninitializedImpl (SizeType Index)
 
template<typename OtherSizeType >
void InsertUninitializedImpl (SizeType Index, OtherSizeType Count)
 
void RemoveAtImpl (SizeType Index, SizeType Count, bool bAllowShrinking)
 
void RemoveAtSwapImpl (SizeType Index, SizeType Count=1, bool bAllowShrinking=true)
 
template<typename ArgsType >
SizeType AddUniqueImpl (ArgsType &&Args)
 
void AllocatorResizeAllocation (SizeType CurrentArrayNum, SizeType NewArrayMax)
 
SizeType AllocatorCalculateSlackShrink (SizeType CurrentArrayNum, SizeType NewArrayMax)
 
SizeType AllocatorCalculateSlackGrow (SizeType CurrentArrayNum, SizeType NewArrayMax)
 
SizeType AllocatorCalculateSlackReserve (SizeType NewArrayMax)
 
FORCENOINLINE void ResizeGrow (SizeType OldNum)
 
FORCENOINLINE void ResizeShrink ()
 
FORCENOINLINE void ResizeTo (SizeType NewMax)
 
FORCENOINLINE void ResizeForCopy (SizeType NewMax, SizeType PrevMax)
 
template<typename OtherElementType , typename OtherSizeType >
void CopyToEmpty (const OtherElementType *OtherData, OtherSizeType OtherNum, SizeType PrevMax)
 
template<typename OtherElementType , typename OtherSizeType >
void CopyToEmptyWithSlack (const OtherElementType *OtherData, OtherSizeType OtherNum, SizeType PrevMax, SizeType ExtraSlack)
 

Static Private Member Functions

static FORCENOINLINE void OnInvalidNum (USizeType NewNum)
 
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE void MoveOrCopy (ToArrayType &ToArray, FromArrayType &FromArray, SizeType PrevMax)
 
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE void MoveOrCopyWithSlack (ToArrayType &ToArray, FromArrayType &FromArray, SizeType PrevMax, SizeType ExtraSlack)
 

Friends

template<typename OtherInElementType , typename OtherAllocator >
class TArray
 
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.

Definition at line 351 of file Array.h.

Member Typedef Documentation

◆ Allocator

◆ AllocatorType

◆ ElementAllocatorType

typedef TChooseClass<AllocatorType::NeedsElementType,typenameAllocatorType::templateForElementType<ElementType>,typenameAllocatorType::ForAnyElementType>::Result TArray< InElementType, InAllocatorType >::ElementAllocatorType

Definition at line 382 of file Array.h.

◆ ElementType

◆ RangedForConstIteratorType

◆ RangedForIteratorType

◆ SizeType

typedef InAllocatorType::SizeType TArray< InElementType, InAllocatorType >::SizeType

Definition at line 357 of file Array.h.

◆ TConstIterator

◆ TIterator

◆ USizeType

Definition at line 362 of file Array.h.

Constructor & Destructor Documentation

◆ TArray() [1/11]

Constructor, initializes element number counters.

Definition at line 389 of file Array.h.

◆ TArray() [2/11]

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

Definition at line 401 of file Array.h.

◆ TArray() [3/11]

◆ TArray() [4/11]

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

Initializer list constructor

Definition at line 419 of file Array.h.

◆ TArray() [5/11]

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

Parameters
OtherThe source array to copy.

Definition at line 437 of file Array.h.

◆ TArray() [6/11]

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

Parameters
OtherThe source array to copy.

Definition at line 447 of file Array.h.

◆ TArray() [7/11]

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.

Definition at line 459 of file Array.h.

◆ TArray() [8/11]

Move constructor.

Parameters
OtherArray to move from.

Definition at line 610 of file Array.h.

◆ TArray() [9/11]

Move constructor.

Parameters
OtherArray to move from.

Definition at line 625 of file Array.h.

◆ TArray() [10/11]

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.

Definition at line 641 of file Array.h.

◆ ~TArray()

Destructor.

Definition at line 662 of file Array.h.

◆ TArray() [11/11]

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

Definition at line 2174 of file Array.h.

◆ 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

Definition at line 2161 of file Array.h.

◆ 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

Definition at line 2202 of file Array.h.

◆ 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

Definition at line 2189 of file Array.h.

◆ 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

Definition at line 2260 of file Array.h.

◆ AddDefaulted() [2/2]

Definition at line 2266 of file Array.h.

◆ 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

Definition at line 2280 of file Array.h.

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

Definition at line 1316 of file Array.h.

◆ AddUninitialized() [2/2]

Definition at line 1329 of file Array.h.

◆ 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

Definition at line 2466 of file Array.h.

◆ 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

Definition at line 2454 of file Array.h.

◆ AddUniqueImpl()

template<typename ArgsType >
SizeType TArray< InElementType, InAllocatorType >::AddUniqueImpl ( ArgsType && Args)
inlineprivate

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

Parameters
ArgsItem to add.
Returns
Index of the element in the array.

Definition at line 2432 of file Array.h.

◆ 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

Definition at line 2220 of file Array.h.

◆ AddZeroed() [2/2]

Definition at line 2226 of file Array.h.

◆ 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

Definition at line 2244 of file Array.h.

◆ AllocatorCalculateSlackGrow()

SizeType TArray< InElementType, InAllocatorType >::AllocatorCalculateSlackGrow ( SizeType CurrentArrayNum,
SizeType NewArrayMax )
inlineprivate

Definition at line 2911 of file Array.h.

◆ AllocatorCalculateSlackReserve()

SizeType TArray< InElementType, InAllocatorType >::AllocatorCalculateSlackReserve ( SizeType NewArrayMax)
inlineprivate

Definition at line 2923 of file Array.h.

◆ AllocatorCalculateSlackShrink()

SizeType TArray< InElementType, InAllocatorType >::AllocatorCalculateSlackShrink ( SizeType CurrentArrayNum,
SizeType NewArrayMax )
inlineprivate

Definition at line 2899 of file Array.h.

◆ AllocatorResizeAllocation()

void TArray< InElementType, InAllocatorType >::AllocatorResizeAllocation ( SizeType CurrentArrayNum,
SizeType NewArrayMax )
inlineprivate

Definition at line 2887 of file Array.h.

◆ Append() [1/6]

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

Definition at line 2012 of file Array.h.

◆ Append() [2/6]

Appends the specified array to this array.

AllocatorType changing version.

Parameters
SourceThe array to append.
See also
Add, Insert

Definition at line 1921 of file Array.h.

◆ Append() [3/6]

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

Definition at line 2414 of file Array.h.

◆ Append() [4/6]

template<typename RangeType , typename RangeValueType = std::remove_reference_t<RangeType>, typename RangeElementType = TElementType_T<RangeValueType>, std::enable_if_t< TAnd< TIsContiguousContainer< RangeValueType >, TNot< UE4Array_Private::TIsTArrayOrDerivedFromTArray< RangeValueType > >, UE4Array_Private::TTypeIsCompatibleWithRangeElementType< ElementType, RangeType > >::Value > * = nullptr>
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

Definition at line 1985 of file Array.h.

◆ Append() [5/6]

FORCEINLINE 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

Definition at line 2026 of file Array.h.

◆ Append() [6/6]

Appends the specified array to this array.

Parameters
SourceThe array to append.
See also
Add, Insert

Definition at line 1947 of file Array.h.

◆ AppendHash()

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

Definition at line 3088 of file Array.h.

◆ begin() [1/2]

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

Definition at line 2799 of file Array.h.

◆ begin() [2/2]

◆ 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

Definition at line 1579 of file Array.h.

◆ CheckInvariants()

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

Definition at line 735 of file Array.h.

◆ Contains()

Checks if this array contains the element.

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

Definition at line 1166 of file Array.h.

◆ ContainsByPredicate()

template<typename Predicate >
FORCEINLINE 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

Definition at line 1186 of file Array.h.

◆ CopyToEmpty()

Copies data from one array into this array. Uses the fast path if the data in question does not need a constructor.

Parameters
SourceThe source array to copy
PrevMaxThe previous allocated size

Definition at line 2995 of file Array.h.

◆ CopyToEmptyWithSlack()

void TArray< InElementType, InAllocatorType >::CopyToEmptyWithSlack ( const OtherElementType * OtherData,
OtherSizeType OtherNum,
SizeType PrevMax,
SizeType ExtraSlack )
inlineprivate

Copies data from one array into this array. Uses the fast path if the data in question does not need a constructor.

Parameters
SourceThe source array to copy
PrevMaxThe previous allocated size
ExtraSlackAdditional amount of memory to allocate at the end of the buffer. Counted in elements.

Definition at line 3022 of file Array.h.

◆ CopyUnfrozen()

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

Definition at line 3074 of file Array.h.

◆ CountBytes()

void TArray< InElementType, InAllocatorType >::CountBytes ( FArchive & Ar) const
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:

Parameters
ArFArchive to bulk serialize this TArray to/from Count bytes needed to serialize this array.
ArArchive to count for.

Definition at line 1301 of file Array.h.

◆ CreateConstIterator()

TConstIterator TArray< InElementType, InAllocatorType >::CreateConstIterator ( ) const
inline

Creates a const iterator for the contents of this array

Returns
The const iterator.

Definition at line 2779 of file Array.h.

◆ CreateIterator()

Creates an iterator for the contents of this array

Returns
The iterator.

Definition at line 2769 of file Array.h.

◆ Emplace()

template<typename... ArgsType>
FORCEINLINE 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

Definition at line 2078 of file Array.h.

◆ Emplace_GetRef()

template<typename... ArgsType>
FORCEINLINE 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.

Definition at line 2115 of file Array.h.

◆ EmplaceAt()

template<typename... ArgsType>
FORCEINLINE 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.

Definition at line 2130 of file Array.h.

◆ EmplaceAt_GetRef()

template<typename... ArgsType>
FORCEINLINE 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.

Definition at line 2144 of file Array.h.

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

Definition at line 1816 of file Array.h.

◆ 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

Definition at line 1146 of file Array.h.

◆ 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

Definition at line 947 of file Array.h.

◆ 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

Definition at line 934 of file Array.h.

◆ 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

Definition at line 1091 of file Array.h.

◆ FindByKey() [2/2]

template<typename KeyType >
FORCEINLINE const ElementType * TArray< InElementType, InAllocatorType >::FindByKey ( 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
Pointer to the first matching element, or nullptr if none is found.
See also
Find

Definition at line 1077 of file Array.h.

◆ 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. true, or nullptr if none is found.
See also
FilterByPredicate, ContainsByPredicate

Definition at line 1124 of file Array.h.

◆ FindByPredicate() [2/2]

template<typename Predicate >
FORCEINLINE const ElementType * TArray< InElementType, InAllocatorType >::FindByPredicate ( Predicate Pred) const
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

Definition at line 1112 of file Array.h.

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

Definition at line 2739 of file Array.h.

◆ FindLast() [1/2]

Finds element within the array starting from the end.

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

Definition at line 980 of file Array.h.

◆ 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

Definition at line 968 of file Array.h.

◆ FindLastByPredicate() [1/2]

template<typename Predicate >
FORCEINLINE 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.

Definition at line 1022 of file Array.h.

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

Definition at line 1001 of file Array.h.

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

Definition at line 716 of file Array.h.

◆ GetAllocatorInstance() [1/2]

Definition at line 3383 of file Array.h.

◆ GetAllocatorInstance() [2/2]

Definition at line 3382 of file Array.h.

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

Definition at line 694 of file Array.h.

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

Definition at line 684 of file Array.h.

◆ GetSlack()

Returns the amount of slack in this array in elements.

See also
Num, Shrink

Definition at line 726 of file Array.h.

◆ GetTypeSize()

Helper function returning the size of the inner type.

Returns
Size in bytes of array type.

Definition at line 704 of file Array.h.

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

Definition at line 3132 of file Array.h.

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

Definition at line 3118 of file Array.h.

◆ HeapPop() [1/2]

void TArray< InElementType, InAllocatorType >::HeapPop ( ElementType & OutItem,
bool bAllowShrinking = true )
inline

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

Parameters
OutItemThe removed item.
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the pop. Default is true.
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.

Definition at line 3244 of file Array.h.

◆ HeapPop() [2/2]

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

Removes the top element from the heap.

Parameters
OutItemThe removed item.
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.

Definition at line 3224 of file Array.h.

◆ HeapPopDiscard() [1/2]

void TArray< InElementType, InAllocatorType >::HeapPopDiscard ( bool bAllowShrinking = true)
inline

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

Parameters
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the discard. Default is true.
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.

Definition at line 3288 of file Array.h.

◆ HeapPopDiscard() [2/2]

template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocatorType >::HeapPopDiscard ( const PREDICATE_CLASS & Predicate,
bool bAllowShrinking = true )
inline

Removes the top element from the heap.

Parameters
PredicatePredicate class instance.
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the discard. Default is true.
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.

Definition at line 3271 of file Array.h.

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

Definition at line 3208 of file Array.h.

◆ HeapPush() [2/4]

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.

Definition at line 3171 of file Array.h.

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

Definition at line 3192 of file Array.h.

◆ HeapPush() [4/4]

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.

Definition at line 3149 of file Array.h.

◆ HeapRemoveAt() [1/2]

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

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

Parameters
IndexPosition at which to remove item.
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the remove (default = true).
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.

Definition at line 3348 of file Array.h.

◆ HeapRemoveAt() [2/2]

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

Removes an element from the heap.

Parameters
IndexPosition at which to remove item.
PredicatePredicate class instance.
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the remove (default = true).
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.

Definition at line 3328 of file Array.h.

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

Definition at line 3377 of file Array.h.

◆ HeapSort() [2/2]

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.

Definition at line 3363 of file Array.h.

◆ HeapTop() [1/2]

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

Returns
The reference to the top element from the heap.

Definition at line 3310 of file Array.h.

◆ HeapTop() [2/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.

Definition at line 3300 of file Array.h.

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

Definition at line 1035 of file Array.h.

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

Definition at line 1055 of file Array.h.

◆ Init()

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.

Definition at line 2496 of file Array.h.

◆ Insert() [1/8]

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

Definition at line 1612 of file Array.h.

◆ Insert() [2/8]

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

Definition at line 1561 of file Array.h.

◆ Insert() [3/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.

Definition at line 1519 of file Array.h.

◆ Insert() [4/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.

Definition at line 2363 of file Array.h.

◆ 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

Definition at line 1593 of file Array.h.

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

Definition at line 1501 of file Array.h.

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

Definition at line 1539 of file Array.h.

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

Definition at line 2388 of file Array.h.

◆ Insert_GetRef() [1/2]

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

Definition at line 1652 of file Array.h.

◆ 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

Definition at line 1632 of file Array.h.

◆ 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

Definition at line 1467 of file Array.h.

◆ InsertDefaulted() [2/2]

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

Definition at line 1472 of file Array.h.

◆ 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

Definition at line 1486 of file Array.h.

◆ 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

Definition at line 1408 of file Array.h.

◆ InsertUninitialized() [2/2]

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

Definition at line 1412 of file Array.h.

◆ InsertUninitializedImpl() [1/2]

void TArray< InElementType, InAllocatorType >::InsertUninitializedImpl ( SizeType Index)
inlineprivate

Definition at line 1352 of file Array.h.

◆ InsertUninitializedImpl() [2/2]

template<typename OtherSizeType >
void TArray< InElementType, InAllocatorType >::InsertUninitializedImpl ( SizeType Index,
OtherSizeType Count )
inlineprivate

Definition at line 1369 of file Array.h.

◆ 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

Definition at line 1429 of file Array.h.

◆ InsertZeroed() [2/2]

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

Definition at line 1434 of file Array.h.

◆ 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

Definition at line 1451 of file Array.h.

◆ IsEmpty()

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

Returns
True if the array is empty.
See also
Num

Definition at line 773 of file Array.h.

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

Definition at line 762 of file Array.h.

◆ Last() [1/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.

Definition at line 892 of file Array.h.

◆ Last() [2/2]

Returns n-th last element from the array.

Const version of the above.

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

Definition at line 906 of file Array.h.

◆ Max()

Returns maximum number of elements in array.

Returns
Maximum number of elements in array.
See also
GetSlack

Definition at line 795 of file Array.h.

◆ MoveOrCopy()

static FORCEINLINE void TArray< InElementType, InAllocatorType >::MoveOrCopy ( ToArrayType & ToArray,
FromArrayType & FromArray,
SizeType PrevMax )
inlinestaticprivate

Moves or copies array. Depends on the array type traits.

Parameters
ToArrayArray to move into.
FromArrayArray to move from.
PrevMaxThe previous allocated size.

Definition at line 524 of file Array.h.

◆ MoveOrCopyWithSlack()

static FORCEINLINE void TArray< InElementType, InAllocatorType >::MoveOrCopyWithSlack ( ToArrayType & ToArray,
FromArrayType & FromArray,
SizeType PrevMax,
SizeType ExtraSlack )
inlinestaticprivate

Moves or copies array. Depends on the array type traits.

Parameters
ToArrayArray to move into.
FromArrayArray to move from.
PrevMaxThe previous allocated size.
ExtraSlackTells how much extra memory should be preallocated at the end of the array in the number of elements.

Definition at line 577 of file Array.h.

◆ Num()

Returns number of elements in array.

Returns
Number of elements in array.
See also
GetSlack

Definition at line 784 of file Array.h.

◆ OnInvalidNum()

Definition at line 364 of file Array.h.

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

Implicit conversion operator to constant container of compatible element type.

Definition at line 2305 of file Array.h.

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

Implicit conversion operator to container of compatible element type.

Definition at line 2293 of file Array.h.

◆ operator!=()

Inequality operator.

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

Definition at line 1211 of file Array.h.

◆ operator+=() [1/3]

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

Parameters
OtherThe array to append.

Definition at line 2054 of file Array.h.

◆ operator+=() [2/3]

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.

Definition at line 2065 of file Array.h.

◆ operator+=() [3/3]

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

Move semantics version.

Parameters
OtherThe array to append.

Definition at line 2042 of file Array.h.

◆ operator=() [1/8]

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

Parameters
OtherThe source array to assign from.

Definition at line 502 of file Array.h.

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

Definition at line 489 of file Array.h.

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

Definition at line 2342 of file Array.h.

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

Definition at line 470 of file Array.h.

◆ operator=() [7/8]

Move assignment operator.

Parameters
OtherArray to assign and move from.

Definition at line 651 of file Array.h.

◆ operator=() [8/8]

Move assignment operator. Compatible element type version.

Parameters
OtherArray to assign and move from.

Definition at line 2322 of file Array.h.

◆ operator==()

Equality operator.

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

Definition at line 1197 of file Array.h.

◆ operator[]() [1/2]

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

Const version of the above.

Returns
Reference to indexed element.

Definition at line 818 of file Array.h.

◆ operator[]() [2/2]

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

Returns
Reference to indexed element.

Definition at line 805 of file Array.h.

◆ Pop()

template<typename ET = InElementType>
FORCEINLINE TEnableIf<!TIsAbstract< ET >::Value, ElementType >::Type TArray< InElementType, InAllocatorType >::Pop ( bool bAllowShrinking = true)
inline

Pops element from the array.

Parameters
bAllowShrinkingIf this call allows shrinking of the array during element remove.
Returns
Popped element.

Definition at line 831 of file Array.h.

◆ Push() [1/2]

Pushes element into the array.

Const ref version of the above.

Parameters
ItemItem to push.
See also
Pop, Top

Definition at line 857 of file Array.h.

◆ Push() [2/2]

Pushes element into the array.

Parameters
ItemItem to push.

Definition at line 844 of file Array.h.

◆ RangeCheck()

Checks if index is in array range.

Parameters
IndexIndex to check.

Definition at line 745 of file Array.h.

◆ 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

Definition at line 2543 of file Array.h.

◆ RemoveAll()

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

Definition at line 2560 of file Array.h.

◆ RemoveAllSwap()

template<class PREDICATE_CLASS >
SizeType TArray< InElementType, InAllocatorType >::RemoveAllSwap ( const PREDICATE_CLASS & Predicate,
bool bAllowShrinking = true )
inline

Remove all instances that match the predicate

Parameters
PredicatePredicate class instance
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.
See also
Remove, RemoveSingle, RemoveSingleSwap, RemoveSwap

Definition at line 2609 of file Array.h.

◆ RemoveAt() [1/2]

Removes an element (or elements) at given location, then shrinks the array.

Parameters
IndexLocation in array of the element to remove.

Definition at line 1701 of file Array.h.

◆ RemoveAt() [2/2]

template<typename CountType >
FORCEINLINE void TArray< InElementType, InAllocatorType >::RemoveAt ( SizeType Index,
CountType Count,
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 1715 of file Array.h.

◆ RemoveAtImpl()

void TArray< InElementType, InAllocatorType >::RemoveAtImpl ( SizeType Index,
SizeType Count,
bool bAllowShrinking )
inlineprivate

Definition at line 1665 of file Array.h.

◆ RemoveAtSwap() [1/2]

Removes an element (or elements) at given location, then shrinks 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.

Definition at line 1762 of file Array.h.

◆ RemoveAtSwap() [2/2]

template<typename CountType >
FORCEINLINE void TArray< InElementType, InAllocatorType >::RemoveAtSwap ( SizeType Index,
CountType Count,
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 1780 of file Array.h.

◆ RemoveAtSwapImpl()

void TArray< InElementType, InAllocatorType >::RemoveAtSwapImpl ( SizeType Index,
SizeType Count = 1,
bool bAllowShrinking = true )
inlineprivate

Definition at line 1722 of file Array.h.

◆ RemoveSingle()

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

Definition at line 2513 of file Array.h.

◆ RemoveSingleSwap()

SizeType TArray< InElementType, InAllocatorType >::RemoveSingleSwap ( const ElementType & Item,
bool bAllowShrinking = true )
inline

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
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.
Returns
The number of items removed. For RemoveSingleItem, this is always either 0 or 1.
See also
Add, Insert, Remove, RemoveAll, RemoveAllSwap, RemoveSwap

Definition at line 2644 of file Array.h.

◆ RemoveSwap()

SizeType TArray< InElementType, InAllocatorType >::RemoveSwap ( const ElementType & Item,
bool bAllowShrinking = true )
inline

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

Returns
Number of elements removed.
See also
Add, Insert, Remove, RemoveAll, RemoveAllSwap

Definition at line 2668 of file Array.h.

◆ 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

Definition at line 2477 of file Array.h.

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

Definition at line 1792 of file Array.h.

◆ ResizeForCopy()

FORCENOINLINE void TArray< InElementType, InAllocatorType >::ResizeForCopy ( SizeType NewMax,
SizeType PrevMax )
inlineprivate

Definition at line 2969 of file Array.h.

◆ ResizeGrow()

Definition at line 2935 of file Array.h.

◆ ResizeShrink()

Definition at line 2947 of file Array.h.

◆ ResizeTo()

Definition at line 2957 of file Array.h.

◆ SetNum()

void TArray< InElementType, InAllocatorType >::SetNum ( SizeType NewNum,
bool bAllowShrinking = true )
inline

Resizes array to given number of elements.

Parameters
NewNumNew size of the array.
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.

Definition at line 1840 of file Array.h.

◆ SetNumUninitialized()

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

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

Parameters
NewNumNew size of the array.

Definition at line 1886 of file Array.h.

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

Definition at line 1906 of file Array.h.

◆ SetNumZeroed()

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

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

Parameters
NewNumNew size of the array.
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.

Definition at line 1865 of file Array.h.

◆ Shrink()

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

See also
Slack

Definition at line 917 of file Array.h.

◆ 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) instead. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 2820 of file Array.h.

◆ Sort() [2/2]

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) instead. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 2836 of file Array.h.

◆ 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. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 2850 of file Array.h.

◆ StableSort() [2/2]

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. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 2867 of file Array.h.

◆ Swap()

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

Definition at line 2714 of file Array.h.

◆ SwapMemory()

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

Definition at line 2697 of file Array.h.

◆ Top() [1/2]

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

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

Definition at line 868 of file Array.h.

◆ Top() [2/2]

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

Const version of the above.

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

Definition at line 881 of file Array.h.

◆ ToString()

Definition at line 3096 of file Array.h.

◆ VerifyHeap()

Verifies the heap.

Parameters
PredicatePredicate class instance.

Definition at line 3255 of file Array.h.

◆ WriteMemoryImage()

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

Definition at line 3057 of file Array.h.

Friends And Related Symbol Documentation

◆ TArray

◆ TArrayPrivateFriend

Definition at line 3385 of file Array.h.

◆ TIndirectArray

Definition at line 3050 of file Array.h.

Member Data Documentation

◆ AllocatorInstance

Definition at line 3052 of file Array.h.

◆ ArrayMax

Definition at line 3054 of file Array.h.

◆ ArrayNum

Definition at line 3053 of file Array.h.


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