Ark Server API (ASE) - Wiki
|
#include <TArray.h>
Public Types | |
typedef InElementType | ElementType |
typedef InAllocator | Allocator |
typedef TIndexedContainerIterator< TArray, ElementType, int32 > | TIterator |
typedef TIndexedContainerIterator< const TArray, const ElementType, int32 > | TConstIterator |
typedef TCheckedPointerIterator< ElementType > | RangedForIteratorType |
typedef TCheckedPointerIterator< const ElementType > | RangedForConstIteratorType |
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) |
TArray & | operator= (std::initializer_list< InElementType > InitList) |
template<typename OtherAllocator > | |
TArray & | operator= (const TArray< ElementType, OtherAllocator > &Other) |
TArray & | operator= (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) | |
TArray & | operator= (TArray &&Other) |
~TArray () | |
FORCEINLINE ElementType * | GetData () 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 ElementType & | operator[] (int32 Index) |
FORCEINLINE const ElementType & | operator[] (int32 Index) const |
FORCEINLINE ElementType | Pop (bool bAllowShrinking=true) |
FORCEINLINE void | Push (ElementType &&Item) |
FORCEINLINE void | Push (const ElementType &Item) |
FORCEINLINE ElementType & | Top () |
FORCEINLINE const ElementType & | Top () const |
FORCEINLINE ElementType & | Last (int32 IndexFromTheEnd=0) |
FORCEINLINE const ElementType & | Last (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 ElementType * | FindByKey (const KeyType &Key) const |
template<typename KeyType > | |
ElementType * | FindByKey (const KeyType &Key) |
template<typename Predicate > | |
FORCEINLINE const ElementType * | FindByPredicate (Predicate Pred) const |
template<typename Predicate > | |
ElementType * | FindByPredicate (Predicate Pred) |
template<typename Predicate > | |
TArray< ElementType > | FilterByPredicate (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) |
TArray & | operator+= (TArray &&Other) |
TArray & | operator+= (const TArray &Other) |
TArray & | operator+= (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) |
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.
typedef InAllocator TArray< InElementType, InAllocator >::Allocator |
|
protected |
typedef InElementType TArray< InElementType, InAllocator >::ElementType |
typedef TCheckedPointerIterator<const ElementType> TArray< InElementType, InAllocator >::RangedForConstIteratorType |
typedef TCheckedPointerIterator< ElementType> TArray< InElementType, InAllocator >::RangedForIteratorType |
typedef TIndexedContainerIterator<const TArray, const ElementType, int32> TArray< InElementType, InAllocator >::TConstIterator |
typedef TIndexedContainerIterator< TArray, ElementType, int32> TArray< InElementType, InAllocator >::TIterator |
|
inline |
|
inline |
Adds a new item to the end of the array, possibly reallocating the whole array to fit.
Item | The item to add |
Definition at line 1564 of file TArray.h.
|
inline |
|
inline |
Adds new items to the end of the array, possibly reallocating the whole array to fit. The new items will be default-constructed.
Count | The number of new items to add. |
|
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.
Count | Number of elements to add. |
Definition at line 1051 of file TArray.h.
|
inline |
|
inline |
|
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.
Count | The number of new items to add. |
|
inline |
|
inline |
|
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.
Addr | The address to check. |
Definition at line 1193 of file TArray.h.
|
inline |
|
inline |
|
inline |
|
inlineprivate |
Copies data from one array into this array. Uses the fast path if the data in question does not need a constructor.
Source | The source array to copy |
PrevMax | The previous allocated size |
ExtraSlack | Additional amount of memory to allocate at the end of the buffer. Counted in elements. Zero by default. |
|
inline |
|
inline |
Filters the elements in the array based on a predicate functor.
Pred | The functor to apply to each element. |
|
inline |
Finds element within the array.
Item | Item to look for. |
|
inline |
Finds element within the array.
Item | Item to look for. |
Index | Will contain the found index. |
|
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
Key | The key to search by. |
|
inline |
|
inline |
Finds an element which matches a predicate functor.
Pred | The functor to apply to each element. true, or nullptr if none is found. |
|
inline |
Finds an element which matches a predicate functor.
Pred | The functor to apply to each element. |
|
inline |
|
inline |
Finds element within the array starting from the end.
Item | Item to look for. |
Index | Output parameter. Found index. |
|
inline |
Searches the array for the last occurrence of an element which matches the specified predicate.
Pred | Predicate taking array element and returns true if element matches search criteria, false otherwise. |
|
inline |
Searches an initial subrange of the array for the last occurrence of an element which matches the specified predicate.
Pred | Predicate taking array element and returns true if element matches search criteria, false otherwise. |
Count | The number of elements from the front of the array through which to search. |
|
inline |
|
inline |
|
inline |
|
inline |
Inserts a raw array of elements at a particular index in the TArray.
Ptr | A pointer to an array of elements to add. |
Count | The number of elements to insert from Ptr. |
Index | The index to insert the elements at. |
|
inline |
|
inline |
|
inline |
|
inline |
Inserts a given number of default-constructed elements into the array at a given location.
Index | Tells where to insert the new elements. |
Count | Number of elements to add. |
|
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.
Index | Tells where to insert the new elements. |
Count | Number of elements to add. |
|
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.
Index | Tells where to insert the new elements. |
Count | Number of elements to add. |
|
inline |
|
inline |
|
inlinestaticprivate |
|
inlinestaticprivate |
|
inlinestaticprivate |
|
inlinestaticprivate |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Removes as many instances of Item as there are in the array, maintaining order but not indices.
Item | Item to remove from array. |
Definition at line 1709 of file TArray.h.
|
inline |
Remove all instances that match the predicate, maintaining order but not indices Optimized to work with runs of matches/non-matches
Predicate | Predicate class instance |
Definition at line 1726 of file TArray.h.
|
inline |
Remove all instances that match the predicate
Predicate | Predicate class instance |
|
inline |
Removes an element (or elements) at given location optionally shrinking the array.
Index | Location 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. |
|
inline |
Removes an element (or elements) at given location optionally shrinking the array.
Index | Location 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. |
|
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.
Index | Location 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. |
|
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.
Index | Location 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. |
|
inline |
Removes the first occurrence of the specified item in the array, maintaining order but not indices.
Item | The item to remove. |
|
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
Item | The item to remove |
|
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.
|
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.
NewSize | The expected usage size after calling this function. |
Definition at line 1302 of file TArray.h.
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inlineprivate |
|
inline |
|
inline |
Sorts the array assuming < operator is defined for the item type.
|
inline |
Sorts the array using user define predicate class.
Predicate | Predicate class instance. |
|
inline |
Stable sorts the array assuming < operator is defined for the item type.
Stable sort is slower than non-stable algorithm.
|
inline |
Stable sorts the array using user defined predicate class.
Stable sort is slower than non-stable algorithm.
Predicate | Predicate class instance |
|
inline |
|
inline |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |