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