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

#include <TArray.h>

+ Collaboration diagram for TArray< InElementType, InAllocator >:

Public Types

typedef InElementType ElementType
 
typedef InAllocator Allocator
 
typedef TIndexedContainerIterator< TArray, ElementType, int32TIterator
 
typedef TIndexedContainerIterator< const TArray, const ElementType, int32TConstIterator
 
typedef TCheckedPointerIterator< ElementTypeRangedForIteratorType
 
typedef TCheckedPointerIterator< const ElementTypeRangedForConstIteratorType
 

Public Member Functions

FORCEINLINE TArray ()
 
FORCEINLINE TArray (const ElementType *Ptr, int32 Count)
 
 TArray (std::initializer_list< InElementType > InitList)
 
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray (const TArray< OtherElementType, OtherAllocator > &Other)
 
FORCEINLINE TArray (const TArray &Other)
 
FORCEINLINE TArray (const TArray &Other, int32 ExtraSlack)
 
TArrayoperator= (std::initializer_list< InElementType > InitList)
 
template<typename OtherAllocator >
TArrayoperator= (const TArray< ElementType, OtherAllocator > &Other)
 
TArrayoperator= (const TArray &Other)
 
FORCEINLINE TArray (TArray &&Other)
 
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray (TArray< OtherElementType, OtherAllocator > &&Other)
 
template<typename OtherElementType >
 TArray (TArray< OtherElementType, Allocator > &&Other, int32 ExtraSlack)
 
TArrayoperator= (TArray &&Other)
 
 ~TArray ()
 
FORCEINLINE ElementTypeGetData () const
 
FORCEINLINE uint32 GetTypeSize () const
 
FORCEINLINE uint32 GetAllocatedSize (void) const
 
FORCEINLINE int32 GetSlack () const
 
FORCEINLINE void CheckInvariants () const
 
FORCEINLINE void RangeCheck (int32 Index) const
 
FORCEINLINE bool IsValidIndex (int32 Index) const
 
FORCEINLINE int32 Num () const
 
FORCEINLINE int32 Max () const
 
FORCEINLINE ElementTypeoperator[] (int32 Index)
 
FORCEINLINE const ElementTypeoperator[] (int32 Index) const
 
FORCEINLINE ElementType Pop (bool bAllowShrinking=true)
 
FORCEINLINE void Push (ElementType &&Item)
 
FORCEINLINE void Push (const ElementType &Item)
 
FORCEINLINE ElementTypeTop ()
 
FORCEINLINE const ElementTypeTop () const
 
FORCEINLINE ElementTypeLast (int32 IndexFromTheEnd=0)
 
FORCEINLINE const ElementTypeLast (int32 IndexFromTheEnd=0) const
 
FORCEINLINE void Shrink ()
 
FORCEINLINE bool Find (const ElementType &Item, int32 &Index) const
 
int32 Find (const ElementType &Item) const
 
FORCEINLINE bool FindLast (const ElementType &Item, int32 &Index) const
 
int32 FindLast (const ElementType &Item) const
 
template<typename Predicate >
int32 FindLastByPredicate (Predicate Pred, int32 Count) const
 
template<typename Predicate >
FORCEINLINE int32 FindLastByPredicate (Predicate Pred) const
 
template<typename KeyType >
int32 IndexOfByKey (const KeyType &Key) const
 
template<typename Predicate >
int32 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
 
FORCEINLINE int32 AddUninitialized (int32 Count=1)
 
void InsertUninitialized (int32 Index, int32 Count=1)
 
void InsertZeroed (int32 Index, int32 Count=1)
 
void InsertDefaulted (int32 Index, int32 Count=1)
 
int32 Insert (std::initializer_list< ElementType > InitList, const int32 InIndex)
 
int32 Insert (const TArray< ElementType > &Items, const int32 InIndex)
 
int32 Insert (const ElementType *Ptr, int32 Count, int32 Index)
 
FORCEINLINE void CheckAddress (const ElementType *Addr) const
 
int32 Insert (ElementType &&Item, int32 Index)
 
int32 Insert (const ElementType &Item, int32 Index)
 
FORCEINLINE void RemoveAt (int32 Index)
 
template<typename CountType >
FORCEINLINE void RemoveAt (int32 Index, CountType Count, bool bAllowShrinking=true)
 
void Reset (int32 NewSize=0)
 
void Empty (int32 Slack=0)
 
void SetNum (int32 NewNum, bool bAllowShrinking=true)
 
void SetNumZeroed (int32 NewNum, bool bAllowShrinking=true)
 
void SetNumUninitialized (int32 NewNum, bool bAllowShrinking=true)
 
void SetNumUnsafeInternal (int32 NewNum)
 
template<typename OtherElementType , typename OtherAllocator >
void Append (const TArray< OtherElementType, OtherAllocator > &Source)
 
template<typename OtherElementType , typename OtherAllocator >
void Append (TArray< OtherElementType, OtherAllocator > &&Source)
 
void Append (const ElementType *Ptr, int32 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 int32 Emplace (ArgsType &&... Args)
 
template<typename... ArgsType>
FORCEINLINE void EmplaceAt (int32 Index, ArgsType &&... Args)
 
FORCEINLINE int32 Add (ElementType &&Item)
 
FORCEINLINE int32 Add (const ElementType &Item)
 
int32 AddZeroed (int32 Count=1)
 
int32 AddDefaulted (int32 Count=1)
 
FORCEINLINE int32 AddUnique (ElementType &&Item)
 
FORCEINLINE int32 AddUnique (const ElementType &Item)
 
FORCEINLINE void Reserve (int32 Number)
 
void Init (const ElementType &Element, int32 Number)
 
int32 RemoveSingle (const ElementType &Item)
 
int32 Remove (const ElementType &Item)
 
template<class PREDICATE_CLASS >
int32 RemoveAll (const PREDICATE_CLASS &Predicate)
 
template<class PREDICATE_CLASS >
void RemoveAllSwap (const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 
int32 RemoveSingleSwap (const ElementType &Item, bool bAllowShrinking=true)
 
int32 RemoveSwap (const ElementType &Item)
 
FORCEINLINE void RemoveAtSwap (int32 Index)
 
template<typename CountType >
FORCEINLINE void RemoveAtSwap (int32 Index, CountType Count, bool bAllowShrinking=true)
 
TIterator CreateIterator ()
 
TConstIterator CreateConstIterator () 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)
 

Protected Types

typedef TChooseClass< Allocator::NeedsElementType, typenameAllocator::templateForElementType< ElementType >, typenameAllocator::ForAnyElementType >::Result ElementAllocatorType
 

Protected Attributes

ElementAllocatorType AllocatorInstance
 
int32 ArrayNum
 
int32 ArrayMax
 

Private Member Functions

void RemoveAtImpl (int32 Index, int32 Count, bool bAllowShrinking)
 
template<typename ArgsType >
int32 AddUniqueImpl (ArgsType &&Args)
 
void RemoveAtSwapImpl (int32 Index, int32 Count=1, bool bAllowShrinking=true)
 
FORCENOINLINE void ResizeGrow (int32 OldNum)
 
FORCENOINLINE void ResizeShrink ()
 
FORCENOINLINE void ResizeTo (int32 NewMax)
 
FORCENOINLINE void ResizeForCopy (int32 NewMax, int32 PrevMax)
 
template<typename OtherElementType >
void CopyToEmpty (const OtherElementType *OtherData, int32 OtherNum, int32 PrevMax, int32 ExtraSlack)
 

Static Private Member Functions

template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf< UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopy (ToArrayType &ToArray, FromArrayType &FromArray, int32 PrevMax)
 
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf<!UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopy (ToArrayType &ToArray, FromArrayType &FromArray, int32 PrevMax)
 
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf< UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopyWithSlack (ToArrayType &ToArray, FromArrayType &FromArray, int32 PrevMax, int32 ExtraSlack)
 
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf<!UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopyWithSlack (ToArrayType &ToArray, FromArrayType &FromArray, int32 PrevMax, int32 ExtraSlack)
 

Friends

template<typename OtherInElementType , typename OtherAllocator >
class TArray
 
FORCEINLINE friend RangedForIteratorType begin (TArray &Array)
 
FORCEINLINE friend RangedForConstIteratorType begin (const TArray &Array)
 
FORCEINLINE friend RangedForIteratorType end (TArray &Array)
 
FORCEINLINE friend RangedForConstIteratorType end (const TArray &Array)
 

Detailed Description

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

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 267 of file TArray.h.

Member Typedef Documentation

◆ Allocator

template<typename InElementType , typename InAllocator >
typedef InAllocator TArray< InElementType, InAllocator >::Allocator

Definition at line 275 of file TArray.h.

◆ ElementAllocatorType

template<typename InElementType , typename InAllocator >
typedef TChooseClass<Allocator::NeedsElementType,typenameAllocator::templateForElementType<ElementType>,typenameAllocator::ForAnyElementType>::Result TArray< InElementType, InAllocator >::ElementAllocatorType
protected

Definition at line 2105 of file TArray.h.

◆ ElementType

template<typename InElementType , typename InAllocator >
typedef InElementType TArray< InElementType, InAllocator >::ElementType

Definition at line 274 of file TArray.h.

◆ RangedForConstIteratorType

template<typename InElementType , typename InAllocator >
typedef TCheckedPointerIterator<const ElementType> TArray< InElementType, InAllocator >::RangedForConstIteratorType

Definition at line 1930 of file TArray.h.

◆ RangedForIteratorType

template<typename InElementType , typename InAllocator >
typedef TCheckedPointerIterator< ElementType> TArray< InElementType, InAllocator >::RangedForIteratorType

Definition at line 1929 of file TArray.h.

◆ TConstIterator

template<typename InElementType , typename InAllocator >
typedef TIndexedContainerIterator<const TArray, const ElementType, int32> TArray< InElementType, InAllocator >::TConstIterator

Definition at line 1906 of file TArray.h.

◆ TIterator

template<typename InElementType , typename InAllocator >
typedef TIndexedContainerIterator< TArray, ElementType, int32> TArray< InElementType, InAllocator >::TIterator

Definition at line 1905 of file TArray.h.

Constructor & Destructor Documentation

◆ TArray() [1/9]

template<typename InElementType , typename InAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( )
inline

Constructor, initializes element number counters.

Definition at line 280 of file TArray.h.

◆ TArray() [2/9]

template<typename InElementType , typename InAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( const ElementType * Ptr,
int32 Count )
inline

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 292 of file TArray.h.

◆ TArray() [3/9]

template<typename InElementType , typename InAllocator >
TArray< InElementType, InAllocator >::TArray ( std::initializer_list< InElementType > InitList)
inline

Initializer list constructor

Definition at line 302 of file TArray.h.

◆ TArray() [4/9]

template<typename InElementType , typename InAllocator >
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( const TArray< OtherElementType, OtherAllocator > & Other)
inlineexplicit

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

Parameters
OtherThe source array to copy.

Definition at line 316 of file TArray.h.

◆ TArray() [5/9]

template<typename InElementType , typename InAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( const TArray< InElementType, InAllocator > & Other)
inline

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

Parameters
OtherThe source array to copy.

Definition at line 326 of file TArray.h.

◆ TArray() [6/9]

template<typename InElementType , typename InAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( const TArray< InElementType, InAllocator > & Other,
int32 ExtraSlack )
inline

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 338 of file TArray.h.

◆ TArray() [7/9]

template<typename InElementType , typename InAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( TArray< InElementType, InAllocator > && Other)
inline

Move constructor.

Parameters
OtherArray to move from.

Definition at line 468 of file TArray.h.

◆ TArray() [8/9]

template<typename InElementType , typename InAllocator >
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray< InElementType, InAllocator >::TArray ( TArray< OtherElementType, OtherAllocator > && Other)
inlineexplicit

Move constructor.

Parameters
OtherArray to move from.

Definition at line 479 of file TArray.h.

◆ TArray() [9/9]

template<typename InElementType , typename InAllocator >
template<typename OtherElementType >
TArray< InElementType, InAllocator >::TArray ( TArray< OtherElementType, Allocator > && Other,
int32 ExtraSlack )
inline

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 492 of file TArray.h.

◆ ~TArray()

template<typename InElementType , typename InAllocator >
TArray< InElementType, InAllocator >::~TArray ( )
inline

Destructor.

Definition at line 517 of file TArray.h.

Member Function Documentation

◆ Add() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::Add ( const ElementType & Item)
inline

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

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

Definition at line 1564 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Add() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::Add ( ElementType && Item)
inline

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 1555 of file TArray.h.

◆ AddDefaulted()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::AddDefaulted ( int32 Count = 1)
inline

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 1593 of file TArray.h.

◆ AddUninitialized()

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::AddUninitialized ( int32 Count = 1)
inline

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 1051 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddUnique() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::AddUnique ( const ElementType & Item)
inline

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

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

Definition at line 1640 of file TArray.h.

◆ AddUnique() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::AddUnique ( ElementType && Item)
inline

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

Move semantics version.

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

Definition at line 1631 of file TArray.h.

◆ AddUniqueImpl()

template<typename InElementType , typename InAllocator >
template<typename ArgsType >
int32 TArray< InElementType, InAllocator >::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 1609 of file TArray.h.

◆ AddZeroed()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::AddZeroed ( int32 Count = 1)
inline

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 1578 of file TArray.h.

◆ Append() [1/4]

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Append ( const ElementType * Ptr,
int32 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

Definition at line 1460 of file TArray.h.

◆ Append() [2/4]

template<typename InElementType , typename InAllocator >
template<typename OtherElementType , typename OtherAllocator >
void TArray< InElementType, InAllocator >::Append ( const TArray< OtherElementType, OtherAllocator > & Source)
inline

Appends the specified array to this array.

Allocator changing version.

Parameters
SourceThe array to append.
See also
Add, Insert

Definition at line 1407 of file TArray.h.

◆ Append() [3/4]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::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 1474 of file TArray.h.

◆ Append() [4/4]

template<typename InElementType , typename InAllocator >
template<typename OtherElementType , typename OtherAllocator >
void TArray< InElementType, InAllocator >::Append ( TArray< OtherElementType, OtherAllocator > && Source)
inline

Appends the specified array to this array.

Parameters
SourceThe array to append.
See also
Add, Insert

Definition at line 1433 of file TArray.h.

◆ CheckAddress()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::CheckAddress ( const ElementType * Addr) const
inline

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 1193 of file TArray.h.

+ Here is the caller graph for this function:

◆ CheckInvariants()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::CheckInvariants ( ) const
inline

Checks array invariants: if array size is greater than zero and less than maximum.

Definition at line 573 of file TArray.h.

+ Here is the caller graph for this function:

◆ Contains()

template<typename InElementType , typename InAllocator >
template<typename ComparisonType >
bool TArray< InElementType, InAllocator >::Contains ( const ComparisonType & Item) const
inline

Checks if this array contains the element.

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

Definition at line 992 of file TArray.h.

+ Here is the call graph for this function:

◆ ContainsByPredicate()

template<typename InElementType , typename InAllocator >
template<typename Predicate >
FORCEINLINE bool TArray< InElementType, InAllocator >::ContainsByPredicate ( Predicate Pred) const
inline

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

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

Definition at line 1012 of file TArray.h.

◆ CopyToEmpty()

template<typename InElementType , typename InAllocator >
template<typename OtherElementType >
void TArray< InElementType, InAllocator >::CopyToEmpty ( const OtherElementType * OtherData,
int32 OtherNum,
int32 PrevMax,
int32 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. Zero by default.

Definition at line 2084 of file TArray.h.

◆ CreateConstIterator()

template<typename InElementType , typename InAllocator >
TConstIterator TArray< InElementType, InAllocator >::CreateConstIterator ( ) const
inline

Creates a const iterator for the contents of this array

Returns
The const iterator.

Definition at line 1923 of file TArray.h.

◆ CreateIterator()

template<typename InElementType , typename InAllocator >
TIterator TArray< InElementType, InAllocator >::CreateIterator ( )
inline

Creates an iterator for the contents of this array

Returns
The iterator.

Definition at line 1913 of file TArray.h.

◆ Emplace()

template<typename InElementType , typename InAllocator >
template<typename... ArgsType>
FORCEINLINE int32 TArray< InElementType, InAllocator >::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 1526 of file TArray.h.

+ Here is the call graph for this function:

◆ EmplaceAt()

template<typename InElementType , typename InAllocator >
template<typename... ArgsType>
FORCEINLINE void TArray< InElementType, InAllocator >::EmplaceAt ( int32 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 1540 of file TArray.h.

◆ Empty()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Empty ( int32 Slack = 0)
inline

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 1321 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FilterByPredicate()

template<typename InElementType , typename InAllocator >
template<typename Predicate >
TArray< ElementType > TArray< InElementType, InAllocator >::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 972 of file TArray.h.

◆ Find() [1/2]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Find ( const ElementType & Item) const
inline

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 773 of file TArray.h.

◆ Find() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE bool TArray< InElementType, InAllocator >::Find ( const ElementType & Item,
int32 & Index ) const
inline

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 760 of file TArray.h.

◆ FindByKey() [1/2]

template<typename InElementType , typename InAllocator >
template<typename KeyType >
ElementType * TArray< InElementType, InAllocator >::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 917 of file TArray.h.

◆ FindByKey() [2/2]

template<typename InElementType , typename InAllocator >
template<typename KeyType >
FORCEINLINE const ElementType * TArray< InElementType, InAllocator >::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 903 of file TArray.h.

◆ FindByPredicate() [1/2]

template<typename InElementType , typename InAllocator >
template<typename Predicate >
ElementType * TArray< InElementType, InAllocator >::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 950 of file TArray.h.

◆ FindByPredicate() [2/2]

template<typename InElementType , typename InAllocator >
template<typename Predicate >
FORCEINLINE const ElementType * TArray< InElementType, InAllocator >::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 938 of file TArray.h.

◆ FindLast() [1/2]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::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.

Definition at line 806 of file TArray.h.

◆ FindLast() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE bool TArray< InElementType, InAllocator >::FindLast ( const ElementType & Item,
int32 & Index ) const
inline

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 794 of file TArray.h.

◆ FindLastByPredicate() [1/2]

template<typename InElementType , typename InAllocator >
template<typename Predicate >
FORCEINLINE int32 TArray< InElementType, InAllocator >::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 848 of file TArray.h.

◆ FindLastByPredicate() [2/2]

template<typename InElementType , typename InAllocator >
template<typename Predicate >
int32 TArray< InElementType, InAllocator >::FindLastByPredicate ( Predicate Pred,
int32 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 827 of file TArray.h.

◆ GetAllocatedSize()

template<typename InElementType , typename InAllocator >
FORCEINLINE uint32 TArray< InElementType, InAllocator >::GetAllocatedSize ( void ) const
inline

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

Returns
Number of bytes allocated by this container.

Definition at line 554 of file TArray.h.

◆ GetData()

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType * TArray< InElementType, InAllocator >::GetData ( ) const
inline

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 533 of file TArray.h.

+ Here is the caller graph for this function:

◆ GetSlack()

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::GetSlack ( ) const
inline

Returns the amount of slack in this array in elements.

See also
Num, Shrink

Definition at line 564 of file TArray.h.

◆ GetTypeSize()

template<typename InElementType , typename InAllocator >
FORCEINLINE uint32 TArray< InElementType, InAllocator >::GetTypeSize ( ) const
inline

Helper function returning the size of the inner type.

Returns
Size in bytes of array type.

Definition at line 543 of file TArray.h.

◆ IndexOfByKey()

template<typename InElementType , typename InAllocator >
template<typename KeyType >
int32 TArray< InElementType, InAllocator >::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 861 of file TArray.h.

◆ IndexOfByPredicate()

template<typename InElementType , typename InAllocator >
template<typename Predicate >
int32 TArray< InElementType, InAllocator >::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 881 of file TArray.h.

◆ Init()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Init ( const ElementType & Element,
int32 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.

Definition at line 1662 of file TArray.h.

◆ Insert() [1/5]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Insert ( const ElementType & Item,
int32 Index )
inline

Inserts a given element into the array at given location.

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

Definition at line 1226 of file TArray.h.

◆ Insert() [2/5]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Insert ( const ElementType * Ptr,
int32 Count,
int32 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

Definition at line 1175 of file TArray.h.

◆ Insert() [3/5]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Insert ( const TArray< ElementType > & Items,
const int32 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.

Definition at line 1150 of file TArray.h.

◆ Insert() [4/5]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Insert ( ElementType && Item,
int32 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 elements.
Returns
Location at which the insert was done.
See also
Add, Remove

Definition at line 1207 of file TArray.h.

◆ Insert() [5/5]

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Insert ( std::initializer_list< ElementType > InitList,
const int32 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.

Definition at line 1129 of file TArray.h.

◆ InsertDefaulted()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::InsertDefaulted ( int32 Index,
int32 Count = 1 )
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 1116 of file TArray.h.

◆ InsertUninitialized()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::InsertUninitialized ( int32 Index,
int32 Count = 1 )
inline

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 1076 of file TArray.h.

◆ InsertZeroed()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::InsertZeroed ( int32 Index,
int32 Count = 1 )
inline

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 1102 of file TArray.h.

◆ IsValidIndex()

template<typename InElementType , typename InAllocator >
FORCEINLINE bool TArray< InElementType, InAllocator >::IsValidIndex ( int32 Index) const
inline

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 600 of file TArray.h.

◆ Last() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType & TArray< InElementType, InAllocator >::Last ( int32 IndexFromTheEnd = 0)
inline

Returns n-th last element from the array.

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

Definition at line 718 of file TArray.h.

◆ Last() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE const ElementType & TArray< InElementType, InAllocator >::Last ( int32 IndexFromTheEnd = 0) const
inline

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 732 of file TArray.h.

◆ Max()

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::Max ( ) const
inline

Returns maximum number of elements in array.

Returns
Maximum number of elements in array.
See also
GetSlack

Definition at line 622 of file TArray.h.

◆ MoveOrCopy() [1/2]

template<typename InElementType , typename InAllocator >
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf< UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type TArray< InElementType, InAllocator >::MoveOrCopy ( ToArrayType & ToArray,
FromArrayType & FromArray,
int32 PrevMax )
inlinestaticprivate

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

This override moves.

Parameters
ToArrayArray to move into.
FromArrayArray to move from.

Definition at line 402 of file TArray.h.

◆ MoveOrCopy() [2/2]

template<typename InElementType , typename InAllocator >
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf<!UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type TArray< InElementType, InAllocator >::MoveOrCopy ( ToArrayType & ToArray,
FromArrayType & FromArray,
int32 PrevMax )
inlinestaticprivate

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

This override copies.

Parameters
ToArrayArray to move into.
FromArrayArray 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 423 of file TArray.h.

◆ MoveOrCopyWithSlack() [1/2]

template<typename InElementType , typename InAllocator >
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf< UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type TArray< InElementType, InAllocator >::MoveOrCopyWithSlack ( ToArrayType & ToArray,
FromArrayType & FromArray,
int32 PrevMax,
int32 ExtraSlack )
inlinestaticprivate

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

This override moves.

Parameters
ToArrayArray to move into.
FromArrayArray 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 439 of file TArray.h.

◆ MoveOrCopyWithSlack() [2/2]

template<typename InElementType , typename InAllocator >
template<typename FromArrayType , typename ToArrayType >
static FORCEINLINE TEnableIf<!UE4Array_Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type TArray< InElementType, InAllocator >::MoveOrCopyWithSlack ( ToArrayType & ToArray,
FromArrayType & FromArray,
int32 PrevMax,
int32 ExtraSlack )
inlinestaticprivate

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

This override copies.

Parameters
ToArrayArray to move into.
FromArrayArray 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 457 of file TArray.h.

◆ Num()

template<typename InElementType , typename InAllocator >
FORCEINLINE int32 TArray< InElementType, InAllocator >::Num ( ) const
inline

Returns number of elements in array.

Returns
Number of elements in array.
See also
GetSlack

Definition at line 611 of file TArray.h.

+ Here is the caller graph for this function:

◆ operator!=()

template<typename InElementType , typename InAllocator >
FORCEINLINE bool TArray< InElementType, InAllocator >::operator!= ( const TArray< InElementType, InAllocator > & OtherArray) const
inline

Inequality operator.

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

Definition at line 1036 of file TArray.h.

◆ operator+=() [1/3]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::operator+= ( const TArray< InElementType, InAllocator > & Other)
inline

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

Parameters
OtherThe array to append.

Definition at line 1502 of file TArray.h.

◆ operator+=() [2/3]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::operator+= ( std::initializer_list< ElementType > InitList)
inline

Appends the specified initializer list to this array.

Parameters
InitListThe initializer list to append.

Definition at line 1513 of file TArray.h.

◆ operator+=() [3/3]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::operator+= ( TArray< InElementType, InAllocator > && Other)
inline

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

Move semantics version.

Parameters
OtherThe array to append.

Definition at line 1490 of file TArray.h.

◆ operator=() [1/4]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::operator= ( const TArray< InElementType, InAllocator > & Other)
inline

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

Parameters
OtherThe source array to assign from.

Definition at line 381 of file TArray.h.

◆ operator=() [2/4]

template<typename InElementType , typename InAllocator >
template<typename OtherAllocator >
TArray & TArray< InElementType, InAllocator >::operator= ( const TArray< ElementType, OtherAllocator > & Other)
inline

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

Allocator changing version.

Parameters
OtherThe source array to assign from.

Definition at line 368 of file TArray.h.

◆ operator=() [3/4]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::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 349 of file TArray.h.

◆ operator=() [4/4]

template<typename InElementType , typename InAllocator >
TArray & TArray< InElementType, InAllocator >::operator= ( TArray< InElementType, InAllocator > && Other)
inline

Move assignment operator.

Parameters
OtherArray to assign and move from.

Definition at line 506 of file TArray.h.

◆ operator==()

template<typename InElementType , typename InAllocator >
bool TArray< InElementType, InAllocator >::operator== ( const TArray< InElementType, InAllocator > & OtherArray) const
inline

Equality operator.

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

Definition at line 1023 of file TArray.h.

◆ operator[]() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType & TArray< InElementType, InAllocator >::operator[] ( int32 Index)
inline

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

Returns
Reference to indexed element.

Definition at line 632 of file TArray.h.

+ Here is the call graph for this function:

◆ operator[]() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE const ElementType & TArray< InElementType, InAllocator >::operator[] ( int32 Index) const
inline

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

Const version of the above.

Returns
Reference to indexed element.

Definition at line 645 of file TArray.h.

◆ Pop()

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType TArray< InElementType, InAllocator >::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 657 of file TArray.h.

◆ Push() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::Push ( const ElementType & Item)
inline

Pushes element into the array.

Const ref version of the above.

Parameters
ItemItem to push.
See also
Pop, Top

Definition at line 683 of file TArray.h.

◆ Push() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::Push ( ElementType && Item)
inline

Pushes element into the array.

Parameters
ItemItem to push.

Definition at line 670 of file TArray.h.

◆ RangeCheck()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::RangeCheck ( int32 Index) const
inline

Checks if index is in array range.

Parameters
IndexIndex to check.

Definition at line 583 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Remove()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::Remove ( const ElementType & Item)
inline

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 1709 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RemoveAll()

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
int32 TArray< InElementType, InAllocator >::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

Definition at line 1726 of file TArray.h.

+ Here is the call graph for this function:

◆ RemoveAllSwap()

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

Remove all instances that match the predicate

Parameters
PredicatePredicate class instance
See also
Remove, RemoveSingle, RemoveSingleSwap, RemoveSwap

Definition at line 1774 of file TArray.h.

◆ RemoveAt() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAt ( int32 Index)
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 1276 of file TArray.h.

◆ RemoveAt() [2/2]

template<typename InElementType , typename InAllocator >
template<typename CountType >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAt ( int32 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 1290 of file TArray.h.

◆ RemoveAtImpl()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::RemoveAtImpl ( int32 Index,
int32 Count,
bool bAllowShrinking )
inlineprivate

Definition at line 1238 of file TArray.h.

◆ RemoveAtSwap() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAtSwap ( int32 Index)
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 1849 of file TArray.h.

◆ RemoveAtSwap() [2/2]

template<typename InElementType , typename InAllocator >
template<typename CountType >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAtSwap ( int32 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 1867 of file TArray.h.

◆ RemoveAtSwapImpl()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::RemoveAtSwapImpl ( int32 Index,
int32 Count = 1,
bool bAllowShrinking = true )
inlineprivate

Definition at line 1873 of file TArray.h.

◆ RemoveSingle()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::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

Definition at line 1679 of file TArray.h.

◆ RemoveSingleSwap()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::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
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 1798 of file TArray.h.

◆ RemoveSwap()

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::RemoveSwap ( const ElementType & Item)
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 1822 of file TArray.h.

◆ Reserve()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::Reserve ( int32 Number)
inline

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

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

Definition at line 1648 of file TArray.h.

◆ Reset()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Reset ( int32 NewSize = 0)
inline

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 1302 of file TArray.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResizeForCopy()

template<typename InElementType , typename InAllocator >
FORCENOINLINE void TArray< InElementType, InAllocator >::ResizeForCopy ( int32 NewMax,
int32 PrevMax )
inlineprivate

Definition at line 2059 of file TArray.h.

◆ ResizeGrow()

template<typename InElementType , typename InAllocator >
FORCENOINLINE void TArray< InElementType, InAllocator >::ResizeGrow ( int32 OldNum)
inlineprivate

Definition at line 2032 of file TArray.h.

+ Here is the caller graph for this function:

◆ ResizeShrink()

template<typename InElementType , typename InAllocator >
FORCENOINLINE void TArray< InElementType, InAllocator >::ResizeShrink ( )
inlineprivate

Definition at line 2037 of file TArray.h.

◆ ResizeTo()

template<typename InElementType , typename InAllocator >
FORCENOINLINE void TArray< InElementType, InAllocator >::ResizeTo ( int32 NewMax)
inlineprivate

Definition at line 2047 of file TArray.h.

+ Here is the caller graph for this function:

◆ SetNum()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::SetNum ( int32 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 1340 of file TArray.h.

◆ SetNumUninitialized()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::SetNumUninitialized ( int32 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 1376 of file TArray.h.

◆ SetNumUnsafeInternal()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::SetNumUnsafeInternal ( int32 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 1392 of file TArray.h.

◆ SetNumZeroed()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::SetNumZeroed ( int32 NewNum,
bool bAllowShrinking = true )
inline

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

Parameters
NewNumNew size of the array.

Definition at line 1359 of file TArray.h.

◆ Shrink()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::Shrink ( )
inline

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

See also
Slack

Definition at line 743 of file TArray.h.

◆ Sort() [1/2]

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Sort ( )
inline

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 1964 of file TArray.h.

◆ Sort() [2/2]

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocator >::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) instead. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 1980 of file TArray.h.

◆ StableSort() [1/2]

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::StableSort ( )
inline

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 1994 of file TArray.h.

◆ StableSort() [2/2]

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocator >::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. The auto-dereferencing behavior does not occur with smart pointers.

Definition at line 2011 of file TArray.h.

◆ Top() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType & TArray< InElementType, InAllocator >::Top ( )
inline

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

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

Definition at line 694 of file TArray.h.

◆ Top() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE const ElementType & TArray< InElementType, InAllocator >::Top ( ) const
inline

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 707 of file TArray.h.

Friends And Related Symbol Documentation

◆ begin [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE friend RangedForConstIteratorType begin ( const TArray< InElementType, InAllocator > & Array)
friend

Definition at line 1944 of file TArray.h.

◆ begin [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE friend RangedForIteratorType begin ( TArray< InElementType, InAllocator > & Array)
friend

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

Definition at line 1943 of file TArray.h.

◆ end [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE friend RangedForConstIteratorType end ( const TArray< InElementType, InAllocator > & Array)
friend

Definition at line 1946 of file TArray.h.

◆ end [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE friend RangedForIteratorType end ( TArray< InElementType, InAllocator > & Array)
friend

Definition at line 1945 of file TArray.h.

◆ TArray

template<typename InElementType , typename InAllocator >
template<typename OtherInElementType , typename OtherAllocator >
friend class TArray
friend

Definition at line 270 of file TArray.h.

Member Data Documentation

◆ AllocatorInstance

template<typename InElementType , typename InAllocator >
ElementAllocatorType TArray< InElementType, InAllocator >::AllocatorInstance
protected

Definition at line 2107 of file TArray.h.

◆ ArrayMax

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::ArrayMax
protected

Definition at line 2109 of file TArray.h.

◆ ArrayNum

template<typename InElementType , typename InAllocator >
int32 TArray< InElementType, InAllocator >::ArrayNum
protected

Definition at line 2108 of file TArray.h.


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