engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 友元 | 所有成员列表
TArray< InElementType, InAllocator > 模板类 参考

Templated dynamic array 更多...

#include <Array.h>

+ 类 TArray< InElementType, InAllocator > 继承关系图:

Public 成员函数

FORCEINLINE SizeType Add (const ElementType &Item)
 Adds a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
FORCEINLINE SizeType Add (ElementType &&Item)
 Adds a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
FORCEINLINE ElementType & Add_GetRef (const ElementType &Item)
 Adds a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
FORCEINLINE ElementType & Add_GetRef (ElementType &&Item)
 Adds a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
SizeType AddDefaulted (SizeType Count=1)
 Adds new items to the end of the array, possibly reallocating the whole array to fit. 更多...
 
ElementType & AddDefaulted_GetRef ()
 Add a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
FORCEINLINE SizeType AddUninitialized (SizeType Count=1)
 Adds a given number of uninitialized elements into the array. 更多...
 
FORCEINLINE SizeType AddUnique (const ElementType &Item)
 Adds unique element to array if it doesn't exist. 更多...
 
FORCEINLINE SizeType AddUnique (ElementType &&Item)
 Adds unique element to array if it doesn't exist. 更多...
 
SizeType AddZeroed (SizeType Count=1)
 Adds new items to the end of the array, possibly reallocating the whole array to fit. 更多...
 
ElementType & AddZeroed_GetRef ()
 Adds a new item to the end of the array, possibly reallocating the whole array to fit. 更多...
 
void Append (const ElementType *Ptr, SizeType Count)
 Adds a raw array of elements to the end of the TArray. 更多...
 
template<typename OtherElementType , typename OtherAllocator >
void Append (const TArray< OtherElementType, OtherAllocator > &Source)
 Appends the specified array to this array. 更多...
 
FORCEINLINE void Append (std::initializer_list< ElementType > InitList)
 Adds an initializer list of elements to the end of the TArray. 更多...
 
template<typename OtherElementType , typename OtherAllocator >
void Append (TArray< OtherElementType, OtherAllocator > &&Source)
 Appends the specified array to this array. 更多...
 
FORCEINLINE RangedForIteratorType begin ()
 DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
 
void BulkSerialize (FArchive &Ar, bool bForcePerElementSerialization=false)
 Bulk serialize array as a single memory blob when loading. 更多...
 
FORCEINLINE void CheckAddress (const ElementType *Addr) const
 Checks that the specified address is not part of an element within the container. 更多...
 
FORCEINLINE void CheckInvariants () const
 Checks array invariants: if array size is greater than zero and less than maximum.
 
template<typename ComparisonType >
bool Contains (const ComparisonType &Item) const
 Checks if this array contains the element. 更多...
 
template<typename Predicate >
FORCEINLINE bool ContainsByPredicate (Predicate Pred) const
 Checks if this array contains element for which the predicate is true. 更多...
 
void CountBytes (FArchive &Ar) const
 Count bytes needed to serialize this array. 更多...
 
TConstIterator CreateConstIterator () const
 Creates a const iterator for the contents of this array 更多...
 
TIterator CreateIterator ()
 Creates an iterator for the contents of this array 更多...
 
template<typename... ArgsType>
FORCEINLINE SizeType Emplace (ArgsType &&... Args)
 Constructs a new item at the end of the array, possibly reallocating the whole array to fit. 更多...
 
template<typename... ArgsType>
FORCEINLINE ElementType & Emplace_GetRef (ArgsType &&... Args)
 Constructs a new item at the end of the array, possibly reallocating the whole array to fit. 更多...
 
template<typename... ArgsType>
FORCEINLINE void EmplaceAt (SizeType Index, ArgsType &&... Args)
 Constructs a new item at a specified index, possibly reallocating the whole array to fit. 更多...
 
template<typename... ArgsType>
FORCEINLINE ElementType & EmplaceAt_GetRef (SizeType Index, ArgsType &&... Args)
 Constructs a new item at a specified index, possibly reallocating the whole array to fit. 更多...
 
void Empty (SizeType Slack=0)
 Empties the array. 更多...
 
template<typename Predicate >
TArray< ElementType > FilterByPredicate (Predicate Pred) const
 Filters the elements in the array based on a predicate functor. 更多...
 
SizeType Find (const ElementType &Item) const
 Finds element within the array. 更多...
 
FORCEINLINE bool Find (const ElementType &Item, SizeType &Index) const
 Finds element within the array. 更多...
 
template<typename KeyType >
ElementType * FindByKey (const KeyType &Key)
 Finds an item by key (assuming the ElementType overloads operator== for the comparison). 更多...
 
template<typename KeyType >
FORCEINLINE const ElementType * FindByKey (const KeyType &Key) const
 Finds an item by key (assuming the ElementType overloads operator== for the comparison). 更多...
 
template<typename Predicate >
ElementType * FindByPredicate (Predicate Pred)
 Finds an element which matches a predicate functor. 更多...
 
template<typename Predicate >
FORCEINLINE const ElementType * FindByPredicate (Predicate Pred) const
 Finds an element which matches a predicate functor. 更多...
 
template<typename SearchType >
bool FindItemByClass (SearchType **Item=nullptr, SizeType *ItemIndex=nullptr, SizeType StartIndex=0) const
 Searches for the first entry of the specified type, will only work with TArray<UObject*>. 更多...
 
SizeType FindLast (const ElementType &Item) const
 Finds element within the array starting from the end. 更多...
 
FORCEINLINE bool FindLast (const ElementType &Item, SizeType &Index) const
 Finds element within the array starting from the end. 更多...
 
template<typename Predicate >
FORCEINLINE SizeType FindLastByPredicate (Predicate Pred) const
 Searches the array for the last occurrence of an element which matches the specified predicate. 更多...
 
template<typename Predicate >
SizeType FindLastByPredicate (Predicate Pred, SizeType Count) const
 Searches an initial subrange of the array for the last occurrence of an element which matches the specified predicate. 更多...
 
FORCEINLINE SIZE_T GetAllocatedSize (void) const
 Helper function to return the amount of memory allocated by this container. 更多...
 
FORCEINLINE ElementType * GetData ()
 Helper function for returning a typed pointer to the first array entry. 更多...
 
FORCEINLINE const ElementType * GetData () const
 Helper function for returning a typed pointer to the first array entry. 更多...
 
FORCEINLINE SizeType GetSlack () const
 Returns the amount of slack in this array in elements. 更多...
 
FORCEINLINE uint32 GetTypeSize () const
 Helper function returning the size of the inner type. 更多...
 
void Heapify ()
 Builds an implicit heap from the array. 更多...
 
template<class PREDICATE_CLASS >
FORCEINLINE void Heapify (const PREDICATE_CLASS &Predicate)
 Implicit heaps 更多...
 
void HeapPop (ElementType &OutItem, bool bAllowShrinking=true)
 Removes the top element from the heap. 更多...
 
template<class PREDICATE_CLASS >
void HeapPop (ElementType &OutItem, const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 Removes the top element from the heap. 更多...
 
void HeapPopDiscard (bool bAllowShrinking=true)
 Removes the top element from the heap. 更多...
 
template<class PREDICATE_CLASS >
void HeapPopDiscard (const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 Removes the top element from the heap. 更多...
 
SizeType HeapPush (const ElementType &InItem)
 Adds a new element to the heap. 更多...
 
template<class PREDICATE_CLASS >
SizeType HeapPush (const ElementType &InItem, const PREDICATE_CLASS &Predicate)
 Adds a new element to the heap. 更多...
 
SizeType HeapPush (ElementType &&InItem)
 Adds a new element to the heap. 更多...
 
template<class PREDICATE_CLASS >
SizeType HeapPush (ElementType &&InItem, const PREDICATE_CLASS &Predicate)
 Adds a new element to the heap. 更多...
 
void HeapRemoveAt (SizeType Index, bool bAllowShrinking=true)
 Removes an element from the heap. 更多...
 
template<class PREDICATE_CLASS >
void HeapRemoveAt (SizeType Index, const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 Removes an element from the heap. 更多...
 
void HeapSort ()
 Performs heap sort on the array. 更多...
 
template<class PREDICATE_CLASS >
void HeapSort (const PREDICATE_CLASS &Predicate)
 Performs heap sort on the array. 更多...
 
ElementType & HeapTop ()
 Returns the top element from the heap (does not remove the element). 更多...
 
const ElementType & HeapTop () const
 Returns the top element from the heap (does not remove the element). 更多...
 
template<typename KeyType >
SizeType IndexOfByKey (const KeyType &Key) const
 Finds an item by key (assuming the ElementType overloads operator== for the comparison). 更多...
 
template<typename Predicate >
SizeType IndexOfByPredicate (Predicate Pred) const
 Finds an item by predicate. 更多...
 
void Init (const ElementType &Element, SizeType Number)
 Sets the size of the array, filling it with the given element. 更多...
 
SizeType Insert (const ElementType &Item, SizeType Index)
 Inserts a given element into the array at given location. 更多...
 
SizeType Insert (const ElementType *Ptr, SizeType Count, SizeType Index)
 Inserts a raw array of elements at a particular index in the TArray. 更多...
 
template<typename OtherAllocator >
SizeType Insert (const TArray< ElementType, OtherAllocator > &Items, const SizeType InIndex)
 Inserts given elements into the array at given location. 更多...
 
SizeType Insert (ElementType &&Item, SizeType Index)
 Inserts a given element into the array at given location. 更多...
 
SizeType Insert (std::initializer_list< ElementType > InitList, const SizeType InIndex)
 Inserts given elements into the array at given location. 更多...
 
template<typename OtherAllocator >
SizeType Insert (TArray< ElementType, OtherAllocator > &&Items, const SizeType InIndex)
 Inserts given elements into the array at given location. 更多...
 
ElementType & Insert_GetRef (const ElementType &Item, SizeType Index)
 Inserts a given element into the array at given location. 更多...
 
ElementType & Insert_GetRef (ElementType &&Item, SizeType Index)
 Inserts a given element into the array at given location. 更多...
 
void InsertDefaulted (SizeType Index, SizeType Count=1)
 Inserts a given number of default-constructed elements into the array at a given location. 更多...
 
ElementType & InsertDefaulted_GetRef (SizeType Index)
 Inserts a default-constructed element into the array at a given location. 更多...
 
FORCEINLINE void InsertUninitialized (SizeType Index, SizeType Count=1)
 Inserts a given number of uninitialized elements into the array at given location. 更多...
 
void InsertZeroed (SizeType Index, SizeType Count=1)
 Inserts a given number of zeroed elements into the array at given location. 更多...
 
ElementType & InsertZeroed_GetRef (SizeType Index)
 Inserts a zeroed element into the array at given location. 更多...
 
FORCEINLINE bool IsValidIndex (SizeType Index) const
 Tests if index is valid, i.e. 更多...
 
FORCEINLINE ElementType & Last (SizeType IndexFromTheEnd=0)
 Returns n-th last element from the array. 更多...
 
FORCEINLINE const ElementType & Last (SizeType IndexFromTheEnd=0) const
 Returns n-th last element from the array. 更多...
 
FORCEINLINE SizeType Max () const
 Returns maximum number of elements in array. 更多...
 
FORCEINLINE SizeType Num () const
 Returns number of elements in array. 更多...
 
FORCEINLINE bool operator!= (const TArray &OtherArray) const
 Inequality operator. 更多...
 
TArray & operator+= (const TArray &Other)
 Appends the specified array to this array. 更多...
 
TArray & operator+= (std::initializer_list< ElementType > InitList)
 Appends the specified initializer list to this array. 更多...
 
TArray & operator+= (TArray &&Other)
 Appends the specified array to this array. 更多...
 
TArray & operator= (const TArray &Other)
 Assignment operator. 更多...
 
template<typename OtherAllocator >
TArray & operator= (const TArray< ElementType, OtherAllocator > &Other)
 Assignment operator. 更多...
 
TArray & operator= (std::initializer_list< InElementType > InitList)
 Initializer list assignment operator. 更多...
 
TArray & operator= (TArray &&Other)
 Move assignment operator. 更多...
 
bool operator== (const TArray &OtherArray) const
 Equality operator. 更多...
 
FORCEINLINE ElementType & operator[] (SizeType Index)
 Array bracket operator. 更多...
 
FORCEINLINE const ElementType & operator[] (SizeType Index) const
 Array bracket operator. 更多...
 
FORCEINLINE ElementType Pop (bool bAllowShrinking=true)
 Pops element from the array. 更多...
 
FORCEINLINE void Push (const ElementType &Item)
 Pushes element into the array. 更多...
 
FORCEINLINE void Push (ElementType &&Item)
 Pushes element into the array. 更多...
 
FORCEINLINE void RangeCheck (SizeType Index) const
 Checks if index is in array range. 更多...
 
SizeType Remove (const ElementType &Item)
 Removes as many instances of Item as there are in the array, maintaining order but not indices. 更多...
 
template<class PREDICATE_CLASS >
SizeType RemoveAll (const PREDICATE_CLASS &Predicate)
 Remove all instances that match the predicate, maintaining order but not indices Optimized to work with runs of matches/non-matches 更多...
 
template<class PREDICATE_CLASS >
SizeType RemoveAllSwap (const PREDICATE_CLASS &Predicate, bool bAllowShrinking=true)
 Remove all instances that match the predicate 更多...
 
FORCEINLINE void RemoveAt (SizeType Index)
 Removes an element (or elements) at given location optionally shrinking the array. 更多...
 
template<typename CountType >
FORCEINLINE void RemoveAt (SizeType Index, CountType Count, bool bAllowShrinking=true)
 Removes an element (or elements) at given location optionally shrinking the array. 更多...
 
FORCEINLINE void RemoveAtSwap (SizeType Index)
 Removes an element (or elements) at given location optionally shrinking the array. 更多...
 
template<typename CountType >
FORCEINLINE void RemoveAtSwap (SizeType Index, CountType Count, bool bAllowShrinking=true)
 Removes an element (or elements) at given location optionally shrinking the array. 更多...
 
SizeType RemoveSingle (const ElementType &Item)
 Removes the first occurrence of the specified item in the array, maintaining order but not indices. 更多...
 
SizeType RemoveSingleSwap (const ElementType &Item, bool bAllowShrinking=true)
 Removes the first occurrence of the specified item in the array. 更多...
 
SizeType RemoveSwap (const ElementType &Item, bool bAllowShrinking=true)
 Removes item from the array. 更多...
 
FORCEINLINE void Reserve (SizeType Number)
 Reserves memory such that the array can contain at least Number elements. 更多...
 
void Reset (SizeType NewSize=0)
 Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array. 更多...
 
void SetNum (SizeType NewNum, bool bAllowShrinking=true)
 Resizes array to given number of elements. 更多...
 
void SetNumUninitialized (SizeType NewNum, bool bAllowShrinking=true)
 Resizes array to given number of elements. 更多...
 
void SetNumUnsafeInternal (SizeType NewNum)
 Does nothing except setting the new number of elements in the array. 更多...
 
void SetNumZeroed (SizeType NewNum, bool bAllowShrinking=true)
 Resizes array to given number of elements. 更多...
 
FORCEINLINE void Shrink ()
 Shrinks the array's used memory to smallest possible to store elements currently in it. 更多...
 
void Sort ()
 Sorts the array assuming < operator is defined for the item type. 更多...
 
template<class PREDICATE_CLASS >
void Sort (const PREDICATE_CLASS &Predicate)
 Sorts the array using user define predicate class. 更多...
 
void StableSort ()
 Stable sorts the array assuming < operator is defined for the item type. 更多...
 
template<class PREDICATE_CLASS >
void StableSort (const PREDICATE_CLASS &Predicate)
 Stable sorts the array using user defined predicate class. 更多...
 
FORCEINLINE void Swap (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 Element-wise array element swap. 更多...
 
FORCEINLINE void SwapMemory (SizeType FirstIndexToSwap, SizeType SecondIndexToSwap)
 Element-wise array memory swap. 更多...
 
FORCEINLINE TArray ()
 Constructor, initializes element number counters.
 
FORCEINLINE TArray (const ElementType *Ptr, SizeType Count)
 Constructor from a raw array of elements. 更多...
 
FORCEINLINE TArray (const TArray &Other)
 Copy constructor. 更多...
 
FORCEINLINE TArray (const TArray &Other, SizeType ExtraSlack)
 Copy constructor. 更多...
 
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray (const TArray< OtherElementType, OtherAllocator > &Other)
 Copy constructor with changed allocator. 更多...
 
 TArray (std::initializer_list< InElementType > InitList)
 Initializer list constructor
 
FORCEINLINE TArray (TArray &&Other)
 Move constructor. 更多...
 
template<typename OtherElementType >
 TArray (TArray< OtherElementType, Allocator > &&Other, SizeType ExtraSlack)
 Move constructor. 更多...
 
template<typename OtherElementType , typename OtherAllocator >
FORCEINLINE TArray (TArray< OtherElementType, OtherAllocator > &&Other)
 Move constructor. 更多...
 
FORCEINLINE ElementType & Top ()
 Returns the top element, i.e. 更多...
 
FORCEINLINE const ElementType & Top () const
 Returns the top element, i.e. 更多...
 
template<class PREDICATE_CLASS >
void VerifyHeap (const PREDICATE_CLASS &Predicate)
 Verifies the heap. 更多...
 
 ~TArray ()
 Destructor.
 

友元

FArchive & operator<< (FArchive &Ar, TArray &A)
 Serialization operator. 更多...
 

详细描述

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.

示例
/github/workspace/Engine/Source/Runtime/UMG/Public/Components/Widget.h.

构造及析构函数说明

◆ TArray() [1/7]

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

Constructor from a raw array of elements.

参数
PtrA pointer to an array of elements to copy.
CountThe number of elements to copy from Ptr.
参见
Append

◆ TArray() [2/7]

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.

参数
OtherThe source array to copy.

◆ TArray() [3/7]

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.

参数
OtherThe source array to copy.

◆ TArray() [4/7]

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

Copy constructor.

Use the common routine to perform the copy.

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

◆ TArray() [5/7]

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

Move constructor.

参数
OtherArray to move from.

◆ TArray() [6/7]

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

Move constructor.

参数
OtherArray to move from.

◆ TArray() [7/7]

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

Move constructor.

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

成员函数说明

◆ Add() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE SizeType 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.

参数
ItemThe item to add
返回
Index to the new item
参见
AddDefaulted, AddUnique, AddZeroed, Append, Insert

◆ Add() [2/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE SizeType 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.

参数
ItemThe item to add
返回
Index to the new item
参见
AddDefaulted, AddUnique, AddZeroed, Append, Insert

◆ Add_GetRef() [1/2]

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

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

参数
ItemThe item to add
返回
A reference to the newly-inserted element.
参见
AddDefaulted_GetRef, AddUnique_GetRef, AddZeroed_GetRef, Insert_GetRef

◆ Add_GetRef() [2/2]

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

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

Move semantics version.

参数
ItemThe item to add
返回
A reference to the newly-inserted element.
参见
AddDefaulted_GetRef, AddUnique_GetRef, AddZeroed_GetRef, Insert_GetRef

◆ AddDefaulted()

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

参数
CountThe number of new items to add.
返回
Index to the first of the new items.
参见
Add, AddZeroed, AddUnique, Append, Insert

◆ AddDefaulted_GetRef()

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

返回
A reference to the newly-inserted element.
参见
Add_GetRef, AddZeroed_GetRef, AddUnique_GetRef, Insert_GetRef

◆ AddUninitialized()

template<typename InElementType , typename InAllocator >
FORCEINLINE SizeType TArray< InElementType, InAllocator >::AddUninitialized ( SizeType  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.

参数
CountNumber of elements to add.
返回
Number of elements in array before addition.

◆ AddUnique() [1/2]

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

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

参数
ArgsItem to add.
返回
Index of the element in the array.
参见
Add, AddDefaulted, AddZeroed, Append, Insert

◆ AddUnique() [2/2]

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

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

Move semantics version.

参数
ArgsItem to add.
返回
Index of the element in the array.
参见
Add, AddDefaulted, AddZeroed, Append, Insert

◆ AddZeroed()

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

参数
CountThe number of new items to add.
返回
Index to the first of the new items.
参见
Add, AddDefaulted, AddUnique, Append, Insert

◆ AddZeroed_GetRef()

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

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.

返回
A reference to the newly-inserted element.
参见
Add_GetRef, AddDefaulted_GetRef, AddUnique_GetRef, Insert_GetRef

◆ Append() [1/4]

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Append ( const ElementType *  Ptr,
SizeType  Count 
)
inline

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

参数
PtrA pointer to an array of elements to add.
CountThe number of elements to insert from Ptr.
参见
Add, Insert

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

参数
SourceThe array to append.
参见
Add, Insert

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

参数
InitListThe initializer list of elements to add.
参见
Add, Insert

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

参数
SourceThe array to append.
参见
Add, Insert

◆ BulkSerialize()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::BulkSerialize ( FArchive &  Ar,
bool  bForcePerElementSerialization = false 
)
inline

Bulk serialize array as a single memory blob when loading.

Uses regular serialization code for saving and doesn't serialize at all otherwise (e.g. transient, garbage collection, ...).

Requirements:

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

Notes:

  • it is safe to call BulkSerialize on TTransArrays

IMPORTANT:

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

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

参数
AddrThe address to check.
参见
Add, Remove

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

返回
True if found. False otherwise.
参见
ContainsByPredicate, FilterByPredicate, FindByPredicate

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

参数
Predicateto use
返回
True if found. False otherwise.
参见
Contains, Find

◆ CountBytes()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::CountBytes ( FArchive &  Ar) const
inline

Count bytes needed to serialize this array.

参数
ArArchive to count for.

◆ CreateConstIterator()

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

Creates a const iterator for the contents of this array

返回
The const iterator.

◆ CreateIterator()

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

Creates an iterator for the contents of this array

返回
The iterator.

◆ Emplace()

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

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

参数
ArgsThe arguments to forward to the constructor of the new item.
返回
Index to the new item

◆ Emplace_GetRef()

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

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

参数
ArgsThe arguments to forward to the constructor of the new item.
返回
A reference to the newly-inserted element.

◆ EmplaceAt()

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

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

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

◆ EmplaceAt_GetRef()

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

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

参数
IndexThe index to add the item at.
ArgsThe arguments to forward to the constructor of the new item.
返回
A reference to the newly-inserted element.

◆ Empty()

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

Empties the array.

It calls the destructors on held items if needed.

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

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

参数
PredThe functor to apply to each element.
返回
TArray with the same type as this object which contains the subset of elements for which the functor returns true.
参见
FindByPredicate, ContainsByPredicate

◆ Find() [1/2]

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

Finds element within the array.

参数
ItemItem to look for.
返回
Index of the found element. INDEX_NONE otherwise.
参见
FindLast, FindLastByPredicate

◆ Find() [2/2]

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

Finds element within the array.

参数
ItemItem to look for.
IndexWill contain the found index.
返回
True if found. False otherwise.
参见
FindLast, FindLastByPredicate

◆ 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

参数
KeyThe key to search by.
返回
Pointer to the first matching element, or nullptr if none is found.
参见
Find

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

参数
KeyThe key to search by.
返回
Pointer to the first matching element, or nullptr if none is found.
参见
Find

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

参数
PredThe functor to apply to each element. true, or nullptr if none is found.
参见
FilterByPredicate, ContainsByPredicate

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

参数
PredThe functor to apply to each element.
返回
Pointer to the first element for which the predicate returns true, or nullptr if none is found.
参见
FilterByPredicate, ContainsByPredicate

◆ FindItemByClass()

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

参数
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.
返回
True if element was found. False otherwise.

◆ FindLast() [1/2]

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

Finds element within the array starting from the end.

参数
ItemItem to look for.
返回
Index of the found element. INDEX_NONE otherwise.

◆ FindLast() [2/2]

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

Finds element within the array starting from the end.

参数
ItemItem to look for.
IndexOutput parameter. Found index.
返回
True if found. False otherwise.
参见
Find, FindLastByPredicate

◆ FindLastByPredicate() [1/2]

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

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

参数
PredPredicate taking array element and returns true if element matches search criteria, false otherwise.
返回
Index of the found element. INDEX_NONE otherwise.

◆ FindLastByPredicate() [2/2]

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

参数
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.
返回
Index of the found element. INDEX_NONE otherwise.

◆ GetAllocatedSize()

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

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.

返回
Number of bytes allocated by this container.

◆ GetData() [1/2]

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

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

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

◆ GetData() [2/2]

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

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

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

◆ GetSlack()

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

Returns the amount of slack in this array in elements.

参见
Num, Shrink

◆ GetTypeSize()

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

Helper function returning the size of the inner type.

返回
Size in bytes of array type.

◆ Heapify() [1/2]

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

Builds an implicit heap from the array.

Assumes < operator is defined for the template type.

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

◆ Heapify() [2/2]

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
FORCEINLINE void TArray< InElementType, InAllocator >::Heapify ( const PREDICATE_CLASS &  Predicate)
inline

Implicit heaps

Builds an implicit heap from the array.

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

◆ HeapPop() [1/2]

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

Removes the top element from the heap.

Assumes < operator is defined for the template type.

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

◆ HeapPop() [2/2]

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

Removes the top element from the heap.

参数
OutItemThe removed item.
PredicatePredicate class instance.
注解
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPopDiscard() [1/2]

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

Removes the top element from the heap.

Assumes < operator is defined for the template type.

参数
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the discard. Default is true.
注解
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your array will be heapified by the values being pointed to, rather than the pointers' values. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPopDiscard() [2/2]

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

Removes the top element from the heap.

参数
PredicatePredicate class instance.
bAllowShrinking(Optional) Tells if this call can shrink the array allocation if suitable after the discard. Default is true.
注解
: If your array contains raw pointers, they will be automatically dereferenced during heapification. Therefore, your predicate will be passed references rather than pointers. The auto-dereferencing behavior does not occur with smart pointers.

◆ HeapPush() [1/4]

template<typename InElementType , typename InAllocator >
SizeType TArray< InElementType, InAllocator >::HeapPush ( const ElementType &  InItem)
inline

Adds a new element to the heap.

Assumes < operator is defined for the template type.

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

◆ HeapPush() [2/4]

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

Adds a new element to the heap.

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

◆ HeapPush() [3/4]

template<typename InElementType , typename InAllocator >
SizeType TArray< InElementType, InAllocator >::HeapPush ( ElementType &&  InItem)
inline

Adds a new element to the heap.

Assumes < operator is defined for the template type.

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

◆ HeapPush() [4/4]

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

Adds a new element to the heap.

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

◆ HeapRemoveAt() [1/2]

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

Removes an element from the heap.

Assumes < operator is defined for the template type.

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

◆ HeapRemoveAt() [2/2]

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

Removes an element from the heap.

参数
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).
注解
: 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.

◆ HeapSort() [1/2]

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

Performs heap sort on the array.

Assumes < operator is defined for the template type.

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

◆ HeapSort() [2/2]

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocator >::HeapSort ( const PREDICATE_CLASS &  Predicate)
inline

Performs heap sort on the array.

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

◆ HeapTop() [1/2]

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

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

返回
The reference to the top element from the heap.

◆ HeapTop() [2/2]

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

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

Const version.

返回
The reference to the top element from the heap.

◆ IndexOfByKey()

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

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

参数
KeyThe key to search by.
返回
Index to the first matching element, or INDEX_NONE if none is found.

◆ IndexOfByPredicate()

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

Finds an item by predicate.

参数
PredThe predicate to match.
返回
Index to the first matching element, or INDEX_NONE if none is found.

◆ Init()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Init ( const ElementType &  Element,
SizeType  Number 
)
inline

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

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

◆ Insert() [1/6]

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

Inserts a given element into the array at given location.

参数
ItemThe element to insert.
IndexTells where to insert the new elements.
返回
Location at which the insert was done.
参见
Add, Remove

◆ Insert() [2/6]

template<typename InElementType , typename InAllocator >
SizeType TArray< InElementType, InAllocator >::Insert ( const ElementType *  Ptr,
SizeType  Count,
SizeType  Index 
)
inline

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

参数
PtrA pointer to an array of elements to add.
CountThe number of elements to insert from Ptr.
IndexThe index to insert the elements at.
返回
The index of the first element inserted.
参见
Add, Remove

◆ Insert() [3/6]

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

Inserts given elements into the array at given location.

参数
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
返回
Location at which the item was inserted.

◆ Insert() [4/6]

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

Inserts a given element into the array at given location.

Move semantics version.

参数
ItemThe element to insert.
IndexTells where to insert the new elements.
返回
Location at which the insert was done.
参见
Add, Remove

◆ Insert() [5/6]

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

Inserts given elements into the array at given location.

参数
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
返回
Location at which the item was inserted.

◆ Insert() [6/6]

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

Inserts given elements into the array at given location.

参数
ItemsArray of elements to insert.
InIndexTells where to insert the new elements.
返回
Location at which the item was inserted.

◆ Insert_GetRef() [1/2]

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

Inserts a given element into the array at given location.

参数
ItemThe element to insert.
IndexTells where to insert the new element.
返回
A reference to the newly-inserted element.
参见
Add, Remove

◆ Insert_GetRef() [2/2]

template<typename InElementType , typename InAllocator >
ElementType & TArray< InElementType, InAllocator >::Insert_GetRef ( ElementType &&  Item,
SizeType  Index 
)
inline

Inserts a given element into the array at given location.

Move semantics version.

参数
ItemThe element to insert.
IndexTells where to insert the new element.
返回
A reference to the newly-inserted element.
参见
Add, Remove

◆ InsertDefaulted()

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

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

参数
IndexTells where to insert the new elements.
CountNumber of elements to add.
参见
Insert, InsertUninitialized, InsertZeroed

◆ InsertDefaulted_GetRef()

template<typename InElementType , typename InAllocator >
ElementType & TArray< InElementType, InAllocator >::InsertDefaulted_GetRef ( SizeType  Index)
inline

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

参数
IndexTells where to insert the new element.
返回
A reference to the newly-inserted element.
参见
Insert_GetRef, InsertZeroed_GetRef

◆ InsertUninitialized()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::InsertUninitialized ( SizeType  Index,
SizeType  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.

参数
IndexTells where to insert the new elements.
CountNumber of elements to add.
参见
Insert, InsertZeroed, InsertDefaulted

◆ InsertZeroed()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::InsertZeroed ( SizeType  Index,
SizeType  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.

参数
IndexTells where to insert the new elements.
CountNumber of elements to add.
参见
Insert, InsertUninitialized, InsertDefaulted

◆ InsertZeroed_GetRef()

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

参数
IndexTells where to insert the new element.
返回
A reference to the newly-inserted element.
参见
Insert_GetRef, InsertDefaulted_GetRef

◆ IsValidIndex()

template<typename InElementType , typename InAllocator >
FORCEINLINE bool TArray< InElementType, InAllocator >::IsValidIndex ( SizeType  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.

参数
IndexIndex to test.
返回
True if index is valid. False otherwise.

◆ Last() [1/2]

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

Returns n-th last element from the array.

参数
IndexFromTheEnd(Optional) Index from the end of array (default = 0).
返回
Reference to n-th last element from the array.

◆ Last() [2/2]

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

Returns n-th last element from the array.

Const version of the above.

参数
IndexFromTheEnd(Optional) Index from the end of array (default = 0).
返回
Reference to n-th last element from the array.

◆ Max()

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

Returns maximum number of elements in array.

返回
Maximum number of elements in array.
参见
GetSlack

◆ Num()

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

Returns number of elements in array.

返回
Number of elements in array.
参见
GetSlack

◆ operator!=()

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

Inequality operator.

参数
OtherArrayArray to compare.
返回
True if this array is NOT the same as OtherArray. False otherwise.

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

参数
OtherThe array to append.

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

参数
InitListThe initializer list to append.

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

参数
OtherThe array to append.

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

参数
OtherThe source array to assign from.

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

参数
OtherThe source array to assign from.

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

参数
InitListThe initializer_list to copy from.

◆ operator=() [4/4]

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

Move assignment operator.

参数
OtherArray to assign and move from.

◆ operator==()

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

Equality operator.

参数
OtherArrayArray to compare.
返回
True if this array is the same as OtherArray. False otherwise.

◆ operator[]() [1/2]

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

Array bracket operator.

Returns reference to element at give index.

返回
Reference to indexed element.

◆ operator[]() [2/2]

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

Array bracket operator.

Returns reference to element at give index.

Const version of the above.

返回
Reference to indexed element.

◆ Pop()

template<typename InElementType , typename InAllocator >
FORCEINLINE ElementType TArray< InElementType, InAllocator >::Pop ( bool  bAllowShrinking = true)
inline

Pops element from the array.

参数
bAllowShrinkingIf this call allows shrinking of the array during element remove.
返回
Popped element.

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

参数
ItemItem to push.
参见
Pop, Top

◆ Push() [2/2]

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

Pushes element into the array.

参数
ItemItem to push.

◆ RangeCheck()

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

Checks if index is in array range.

参数
IndexIndex to check.

◆ Remove()

template<typename InElementType , typename InAllocator >
SizeType 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.

参数
ItemItem to remove from array.
返回
Number of removed elements.
参见
Add, Insert, RemoveAll, RemoveAllSwap, RemoveSingle, RemoveSwap

◆ RemoveAll()

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
SizeType 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

参数
PredicatePredicate class instance
返回
Number of removed elements.
参见
Add, Insert, RemoveAllSwap, RemoveSingle, RemoveSwap

◆ RemoveAllSwap()

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

Remove all instances that match the predicate

参数
PredicatePredicate class instance
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.
参见
Remove, RemoveSingle, RemoveSingleSwap, RemoveSwap

◆ RemoveAt() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAt ( SizeType  Index)
inline

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

参数
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.

◆ RemoveAt() [2/2]

template<typename InElementType , typename InAllocator >
template<typename CountType >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAt ( SizeType  Index,
CountType  Count,
bool  bAllowShrinking = true 
)
inline

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

参数
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.

◆ RemoveAtSwap() [1/2]

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::RemoveAtSwap ( SizeType  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.

参数
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.

◆ RemoveAtSwap() [2/2]

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

参数
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.

◆ RemoveSingle()

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

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

参数
ItemThe item to remove.
返回
The number of items removed. For RemoveSingleItem, this is always either 0 or 1.
参见
Add, Insert, Remove, RemoveAll, RemoveAllSwap

◆ RemoveSingleSwap()

template<typename InElementType , typename InAllocator >
SizeType 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

参数
ItemThe item to remove
bAllowShrinkingTell if this function can shrink the memory in-use if suitable.
返回
The number of items removed. For RemoveSingleItem, this is always either 0 or 1.
参见
Add, Insert, Remove, RemoveAll, RemoveAllSwap, RemoveSwap

◆ RemoveSwap()

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

返回
Number of elements removed.
参见
Add, Insert, Remove, RemoveAll, RemoveAllSwap

◆ Reserve()

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

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

参数
NumberThe number of elements that the array should be able to contain after allocation.
参见
Shrink

◆ Reset()

template<typename InElementType , typename InAllocator >
void TArray< InElementType, InAllocator >::Reset ( SizeType  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.

参数
NewSizeThe expected usage size after calling this function.

◆ SetNum()

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

Resizes array to given number of elements.

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

◆ SetNumUninitialized()

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

Resizes array to given number of elements.

New elements will be uninitialized.

参数
NewNumNew size of the array.

◆ SetNumUnsafeInternal()

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

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

◆ SetNumZeroed()

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

Resizes array to given number of elements.

New elements will be zeroed.

参数
NewNumNew size of the array.

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

参见
Slack

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

注解
: 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.

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

参数
PredicatePredicate class instance.
注解
: 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.

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

注解
: 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.

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

参数
PredicatePredicate class instance
注解
: 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.

◆ Swap()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::Swap ( SizeType  FirstIndexToSwap,
SizeType  SecondIndexToSwap 
)
inline

Element-wise array element swap.

This version is doing more sanity checks than SwapMemory.

参数
FirstIndexToSwapPosition of the first element to swap.
SecondIndexToSwapPosition of the second element to swap.

◆ SwapMemory()

template<typename InElementType , typename InAllocator >
FORCEINLINE void TArray< InElementType, InAllocator >::SwapMemory ( SizeType  FirstIndexToSwap,
SizeType  SecondIndexToSwap 
)
inline

Element-wise array memory swap.

参数
FirstIndexToSwapPosition of the first element to swap.
SecondIndexToSwapPosition of the second element to swap.

◆ Top() [1/2]

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

Returns the top element, i.e.

the last one.

返回
Reference to the top element.
参见
Pop, Push

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

返回
Reference to the top element.
参见
Pop, Push

◆ VerifyHeap()

template<typename InElementType , typename InAllocator >
template<class PREDICATE_CLASS >
void TArray< InElementType, InAllocator >::VerifyHeap ( const PREDICATE_CLASS &  Predicate)
inline

Verifies the heap.

参数
PredicatePredicate class instance.

友元及相关函数文档

◆ operator<<

template<typename InElementType , typename InAllocator >
FArchive & operator<< ( FArchive &  Ar,
TArray< InElementType, InAllocator > &  A 
)
friend

Serialization operator.

参数
ArArchive to serialize the array with.
AArray to serialize.
返回
Passing the given archive.

该类的文档由以下文件生成: