Navigation
API > API/Runtime > API/Runtime/uLangCore
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 TArrayG 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.
| Name | TArrayG |
| Type | class |
| Header File | /Engine/Source/Runtime/Solaris/uLangCore/Public/uLang/Common/Containers/Array.h |
| Include Path | #include "uLang/Common/Containers/Array.h" |
Syntax
template<typename InElementType, typename InElementAllocatorType, typename... RawAllocatorArgsType>
class TArrayG
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ULANG_FORCEINLINE TArrayG
(
RawAllocatorArgsType&&... RawAllocatorArgs |
Constructor with given raw allocator arguments (none required for heap allocator). | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE TArrayG
(
const typename ElementAllocatorType::RawAllocatorType& RawAllocator |
Constructor with given raw allocator. | uLang/Common/Containers/Array.h | |
| Copy constructor. Use the common routine to perform the copy. | uLang/Common/Containers/Array.h | ||
| Move constructor. | uLang/Common/Containers/Array.h | ||
| Move constructor. | uLang/Common/Containers/Array.h | ||
TArrayG
(
std::initializer_list< InElementType > InitList, |
Initializer list constructor | uLang/Common/Containers/Array.h | |
TArrayG
(
std::initializer_list< OtherElementType > InitList, |
uLang/Common/Containers/Array.h | ||
| Copy constructor with changed allocator. Use the common routine to perform the copy. | uLang/Common/Containers/Array.h | ||
| Copy constructor. Use the common routine to perform the copy. | uLang/Common/Containers/Array.h | ||
| Move constructor. | uLang/Common/Containers/Array.h | ||
ULANG_FORCEINLINE TArrayG
(
const ElementType* Ptr, |
Constructor from a raw array of elements. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE TArrayG
(
int32_t Count, |
uLang/Common/Containers/Array.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TArrayG() |
Destructor. | uLang/Common/Containers/Array.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementAllocatorType | InElementAllocatorType | uLang/Common/Containers/Array.h | |
| ElementStorageType | typename TChooseClass< ElementAllocatorType::NeedsElementType, typename ElementAllocatorType::template ForElementType< ElementType >, typename ElementAllocatorType::ForAnyElementType >::Result | uLang/Common/Containers/Array.h | |
| ElementType | InElementType | uLang/Common/Containers/Array.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ULANG_FORCEINLINE int32_t Add
(
const ElementType& Item |
Adds a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t Add
(
ElementType&& Item |
Adds a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & Add_GetRef
(
ElementType&& Item |
Adds a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & Add_GetRef
(
const ElementType& Item |
Adds a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
int32_t AddDefaulted
(
int32_t Count |
Adds new items to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ElementType & AddDefaulted_GetRef () |
Add a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t AddUninitialized
(
int32_t Count |
Adds a given number of uninitialized elements into the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t AddUnique
(
const ElementType& Item |
Adds unique element to array if it doesn't exist. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t AddUnique
(
ElementType&& Item |
Adds unique element to array if it doesn't exist.Move semantics version. | uLang/Common/Containers/Array.h | |
int32_t AddZeroed
(
int32_t Count |
Adds new items to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ElementType & AddZeroed_GetRef () |
Adds a new item to the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
void Append
(
const ElementType* Ptr, |
Adds a raw array of elements to the end of the TArrayG. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void Append
(
std::initializer_list< ElementType > InitList |
Adds an initializer list of elements to the end of the TArrayG. | uLang/Common/Containers/Array.h | |
| Appends the specified array to this array. | uLang/Common/Containers/Array.h | ||
| Appends the specified array to this array.Allocator changing version. | uLang/Common/Containers/Array.h | ||
ULANG_FORCEINLINE const ElementType * begin () |
uLang/Common/Containers/Array.h | ||
ULANG_FORCEINLINEElementType * begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void CheckAddress
(
void const* Addr |
Checks that the specified address is not part of an element within the container. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void CheckInvariants() |
Checks array invariants: if array size is greater than zero and less than maximum. | uLang/Common/Containers/Array.h | |
bool Contains
(
const ComparisonType& Item |
Checks if this array contains the element. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool ContainsByPredicate
(
Predicate Pred |
Checks if this array contains element for which the predicate is true. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t Emplace
(
ArgsType&&... Args |
Constructs a new item at the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & Emplace_GetRef
(
ArgsType&&... Args |
Constructs a new item at the end of the array, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void EmplaceAt
(
int32_t Index, |
Constructs a new item at a specified index, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & EmplaceAt_GetRef
(
int32_t Index, |
Constructs a new item at a specified index, possibly reallocating the whole array to fit. | uLang/Common/Containers/Array.h | |
void Empty
(
int32_t Slack |
Empties the array. It calls the destructors on held items if needed. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType * end () |
uLang/Common/Containers/Array.h | ||
ULANG_FORCEINLINE const ElementType * end () |
uLang/Common/Containers/Array.h | ||
TArrayG FilterByPredicate
(
Predicate Pred |
Filters the elements in the array based on a predicate functor. | uLang/Common/Containers/Array.h | |
int32_t Find
(
const ElementType& Item |
Finds element within the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool Find
(
const ElementType& Item, |
Finds element within the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType * FindByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). | uLang/Common/Containers/Array.h | |
ElementType * FindByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). | uLang/Common/Containers/Array.h | |
ElementType * FindByPredicate
(
Predicate Pred |
Finds an element which matches a predicate functor. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType * FindByPredicate
(
Predicate Pred |
Finds an element which matches a predicate functor. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool FindLast
(
const ElementType& Item, |
Finds element within the array starting from the end. | uLang/Common/Containers/Array.h | |
int32_t FindLast
(
const ElementType& Item |
Finds element within the array starting from the end. | uLang/Common/Containers/Array.h | |
int32_t FindLastByPredicate
(
Predicate Pred, |
Searches an initial subrange of the array for the last occurrence of an element which matches the specified predicate. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t FindLastByPredicate
(
Predicate Pred |
Searches the array for the last occurrence of an element which matches the specified predicate. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE uint32_t GetAllocatedSize () |
Helper function to return the amount of memory allocated by this container. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType * GetData () |
Helper function for returning a typed pointer to the first array entry. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType * GetData () |
Helper function for returning a typed pointer to the first array entry. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementAllocatorType::RawAllocatorType & GetRawAllocator() |
Accesses the raw allocator. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t GetSlack () |
Returns the amount of slack in this array in elements. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE uint32_t GetTypeSize() |
Helper function returning the size of the inner type. | uLang/Common/Containers/Array.h | |
int32_t IndexOfByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). | uLang/Common/Containers/Array.h | |
int32_t IndexOfByPredicate
(
Predicate Pred |
Finds an item by predicate. | uLang/Common/Containers/Array.h | |
void Init
(
const ElementType& Element, |
Sets the size of the array, filling it with the given element. | uLang/Common/Containers/Array.h | |
int32_t Insert
(
ElementType&& Item, |
Inserts a given element into the array at given location. Move semantics version. | uLang/Common/Containers/Array.h | |
int32_t Insert
(
const ElementType& Item, |
Inserts a given element into the array at given location. | uLang/Common/Containers/Array.h | |
int32_t Insert
(
std::initializer_list< ElementType > InitList, |
Inserts given elements into the array at given location. | uLang/Common/Containers/Array.h | |
| Inserts given elements into the array at given location. | uLang/Common/Containers/Array.h | ||
int32_t Insert
(
const ElementType* Ptr, |
Inserts a raw array of elements at a particular index in the TArrayG. | uLang/Common/Containers/Array.h | |
| Inserts given elements into the array at given location. | uLang/Common/Containers/Array.h | ||
ElementType & Insert_GetRef
(
ElementType&& Item, |
Inserts a given element into the array at given location. Move semantics version. | uLang/Common/Containers/Array.h | |
ElementType & Insert_GetRef
(
const ElementType& Item, |
Inserts a given element into the array at given location. | uLang/Common/Containers/Array.h | |
void InsertDefaulted
(
int32_t Index, |
Inserts a given number of default-constructed elements into the array at a given location. | uLang/Common/Containers/Array.h | |
ElementType & InsertDefaulted_GetRef
(
int32_t Index |
Inserts a default-constructed element into the array at a given location. | uLang/Common/Containers/Array.h | |
void InsertUninitialized
(
int32_t Index, |
Inserts a given number of uninitialized elements into the array at given location. | uLang/Common/Containers/Array.h | |
void InsertZeroed
(
int32_t Index, |
Inserts a given number of zeroed elements into the array at given location. | uLang/Common/Containers/Array.h | |
ElementType & InsertZeroed_GetRef
(
int32_t Index |
Inserts a zeroed element into the array at given location. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool IsEmpty () |
Returns true if no elements in array | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool IsFilled () |
Returns true if any elements in array | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE bool IsValidIndex
(
int32_t Index |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & Last
(
int32_t IndexFromTheEnd |
Returns n-th last element from the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType & Last
(
int32_t IndexFromTheEnd |
Returns n-th last element from the array.Const version of the above. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t Max () |
Returns maximum number of elements in array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE int32_t Num () |
Returns number of elements in array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType Pop
(
bool bAllowShrinking |
Pops element from the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void Push
(
ElementType&& Item |
Pushes element into the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void Push
(
const ElementType& Item |
Pushes element into the array.Const ref version of the above. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void RangeCheck
(
int32_t Index |
Checks if index is in array range. | uLang/Common/Containers/Array.h | |
int32_t Remove
(
const OtherElementType& Item |
Removes as many instances of Item as there are in the array, maintaining order but not indices. | uLang/Common/Containers/Array.h | |
int32_t 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 | uLang/Common/Containers/Array.h | |
void RemoveAllSwap
(
const PREDICATE_CLASS& Predicate, |
Remove all instances that match the predicate | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void RemoveAt
(
int32_t Index |
Removes an element (or elements) at given location optionally shrinking the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void RemoveAt
(
int32_t Index, |
Removes an element (or elements) at given location optionally shrinking the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void RemoveAtSwap
(
int32_t Index |
Removes an element (or elements) at given location optionally shrinking the array. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void RemoveAtSwap
(
int32_t Index, |
Removes an element (or elements) at given location optionally shrinking the array. | uLang/Common/Containers/Array.h | |
int32_t RemoveSingle
(
const ElementType& Item |
Removes the first occurrence of the specified item in the array, maintaining order but not indices. | uLang/Common/Containers/Array.h | |
int32_t RemoveSingleSwap
(
const ElementType& Item, |
Removes the first occurrence of the specified item in the array. | uLang/Common/Containers/Array.h | |
void RemoveSuccessiveDuplicates() |
Remove successive duplicates. Assumes that elements of the array have ==. | uLang/Common/Containers/Array.h | |
int32_t RemoveSwap
(
const ElementType& Item |
Removes item from the array. | uLang/Common/Containers/Array.h | |
int32_t Replace
(
const ElementType& OldItem, |
Replaces specified element with the supplied element. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void Reserve
(
int32_t Number |
Reserves memory such that the array can contain at least Number elements. | uLang/Common/Containers/Array.h | |
void Reset
(
int32_t NewSize |
Same as empty, but doesn't change memory allocations, unless the new size is larger than the current array. | uLang/Common/Containers/Array.h | |
void SetNum
(
int32_t NewNum, |
Resizes array to given number of elements. | uLang/Common/Containers/Array.h | |
void SetNumUninitialized
(
int32_t NewNum, |
Resizes array to given number of elements. New elements will be uninitialized. | uLang/Common/Containers/Array.h | |
void SetNumUnsafeInternal
(
int32_t NewNum |
Does nothing except setting the new number of elements in the array. | uLang/Common/Containers/Array.h | |
void SetNumZeroed
(
int32_t NewNum, |
Resizes array to given number of elements. New elements will be zeroed. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE void Shrink () |
Shrinks the array's used memory to smallest possible to store elements currently in it. | uLang/Common/Containers/Array.h | |
void Sort
(
const PredicateType& Predicate |
Sorts the array using user define predicate class. | uLang/Common/Containers/Array.h | |
void Sort () |
Sorts the array assuming < operator is defined for the item type. | uLang/Common/Containers/Array.h | |
void StableSort
(
const PredicateType& Predicate |
uLang/Common/Containers/Array.h | ||
ULANG_FORCEINLINEElementType & Top () |
Returns the top element, i.e. the last one. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType & Top () |
Returns the top element, i.e. the last one.Const version of the above. | uLang/Common/Containers/Array.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static ULANG_FORCEINLINETEnableIfPrivate::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopy
(
ToArrayType& ToArray, |
Moves or copies array. Depends on the array type traits.This override copies. | uLang/Common/Containers/Array.h | |
static ULANG_FORCEINLINETEnableIf< Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopy
(
ToArrayType& ToArray, |
Moves or copies array. Depends on the array type traits.This override moves. | uLang/Common/Containers/Array.h | |
static ULANG_FORCEINLINETEnableIf< Private::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopyWithSlack
(
ToArrayType& ToArray, |
Moves or copies array. Depends on the array type traits.This override moves. | uLang/Common/Containers/Array.h | |
static ULANG_FORCEINLINETEnableIfPrivate::TCanMoveTArrayPointersBetweenArrayTypes< FromArrayType, ToArrayType >::Value >::Type MoveOrCopyWithSlack
(
ToArrayType& ToArray, |
Moves or copies array. Depends on the array type traits.This override copies. | uLang/Common/Containers/Array.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ULANG_FORCEINLINE bool operator!=
(
const TArrayG& OtherArray |
Inequality operator. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINEElementType & operator[]
(
int32_t Index |
Array bracket operator. Returns reference to element at give index. | uLang/Common/Containers/Array.h | |
ULANG_FORCEINLINE const ElementType & operator[]
(
int32_t Index |
Array bracket operator. Returns reference to element at give index.Const version of the above. | uLang/Common/Containers/Array.h | |
TArrayG & operator+=
(
TArrayG&& Other |
Appends the specified array to this array. Cannot append to self.Move semantics version. | uLang/Common/Containers/Array.h | |
TArrayG & operator+=
(
const TArrayG& Other |
Appends the specified array to this array. Cannot append to self. | uLang/Common/Containers/Array.h | |
TArrayG & operator+=
(
std::initializer_list< ElementType > InitList |
Appends the specified initializer list to this array. | uLang/Common/Containers/Array.h | |
| Assignment operator. | uLang/Common/Containers/Array.h | ||
| Move assignment operator. | uLang/Common/Containers/Array.h | ||
bool operator==
(
const TArrayG& OtherArray |
Equality operator. | uLang/Common/Containers/Array.h |