Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Containers
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Containers/SparseArray.h |
Include | #include "Containers/SparseArray.h" |
Syntax
template<typename InElementType, typename Allocator>
class TSparseArray
Remarks
A dynamically sized array where element indices aren't necessarily contiguous. Memory is allocated for all elements in the array's index range, so it doesn't save memory; but it does allow O(1) element removal that doesn't invalidate the indices of subsequent elements. It uses TArray to store the elements, and a TBitArray to store whether each element index is allocated (for fast iteration over allocated elements).
Variables
Type | Name | Description | |
---|---|---|---|
![]() |
*: Add(A) -> [1] | Frame2 | Sort the free element list so that subsequent allocations will occur in the lowest available position resulting in tighter packing without moving any existing items. |
![]() |
Free list is | now |
Destructors
Type | Name | Description | |
---|---|---|---|
![]() |
Destructor. |
Functions
Type | Name | Description | |
---|---|---|---|
![]() |
Add
(
B |
||
![]() |
int32 | Add
(
ElementType&& Element |
Adds an element to the array. |
![]() |
int32 | Add
(
const ElementType& Element |
Adds an element to the array. |
![]() |
FSparseArrayAllocationInfo | Allocates space for an element in the array. | |
![]() |
FSparseArrayAllocationInfo | AddUninitializedAtLowestFreeIndex
(
int32& LowestFreeIndexSearchStart |
|
![]() |
FSparseArrayAllocationInfo | AllocateIndex
(
int32 Index |
Marks an index as allocated, and returns information about the allocation. |
![]() ![]() |
void | AppendHash
(
const FPlatformTypeLayoutParameters& LayoutParams, |
|
![]() ![]() |
FORCEINLINETRangedForConstIterator | begin () |
|
![]() |
FORCEINLINETRangedForIterator | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. |
![]() |
bool | Compact () |
Compacts the allocated elements into a contiguous index range. |
![]() |
bool | Compacts the allocated elements into a contiguous index range. | |
![]() ![]() |
void | CopyUnfrozen
(
const FMemoryUnfreezeContent& Context, |
|
![]() ![]() |
TConstIterator | Creates a const iterator for the contents of this array | |
![]() |
TIterator | Creates an iterator for the contents of this array | |
![]() |
int32 | Emplace
(
ArgsType&&... Args |
Constructs a new item at the last freed index of the array. |
![]() |
int32 | EmplaceAt
(
int32 Index, |
Constructs a new item at a given index of the array. |
![]() |
int32 | EmplaceAtLowestFreeIndex
(
int32& LowestFreeIndexSearchStart, |
Constructs a new item at the lowest free index of the array. |
![]() |
void | Empty
(
int32 ExpectedNumElements |
Removes all elements from the array, potentially leaving space allocated for an expected number of elements about to be added. |
![]() ![]() |
FORCEINLINETRangedForConstIterator | end () |
|
![]() |
FORCEINLINETRangedForIterator | end () |
|
![]() |
void | Insert
(
int32 Index, |
Inserts an element to the array. |
![]() |
FSparseArrayAllocationInfo | InsertUninitialized
(
int32 Index |
Allocates space for an element in the array at a given index. |
![]() |
Remove
(
B |
||
![]() |
Remove
(
A |
||
![]() |
void | RemoveAt
(
int32 Index, |
Removes Count elements from the array, starting from Index. |
![]() |
void | RemoveAtUninitialized
(
int32 Index, |
Removes Count elements from the array, starting from Index, without destructing them. |
![]() |
void | Reserve
(
int32 ExpectedNumElements |
Preallocates enough memory to contain the specified number of elements. |
![]() |
void | Reset () |
Empties the array, but keep its allocated memory as slack. |
![]() |
void | Shrink () |
Shrinks the array's storage to avoid slack. |
![]() |
void | Sort () |
Sorts the elements assuming < operator is defined for ElementType. |
![]() |
void | Sort
(
const PREDICATE_CLASS& Predicate |
Sorts the elements using the provided comparison class. |
![]() |
void | StableSort () |
Stable sorts the elements assuming < operator is defined for ElementType. |
![]() |
void | StableSort
(
const PREDICATE_CLASS& Predicate |
Stable sorts the elements using the provided comparison class. |
![]() ![]() |
void | WriteMemoryImage
(
FMemoryImageWriter& Writer |
Operators
Type | Name | Description | |
---|---|---|---|
![]() |
TSparseArray & | operator+=
(
const TArray< ElementType >& OtherArray |
|
![]() |
TSparseArray & | operator+=
(
const TSparseArray& OtherArray |
Concatenation operators |
Classes
Type | Name | Description | |
---|---|---|---|
![]() |
TConstIterator | Iterates over all allocated elements in a const sparse array. | |
![]() |
TConstSubsetIterator | An iterator which only iterates over the elements of the array which correspond to set bits in a separate bit array. | |
![]() |
TIterator | Iterates over all allocated elements in a sparse array. | |
![]() |
TRangedForConstIterator | ||
![]() |
TRangedForIterator |
Typedefs
Name | Description |
---|---|
AllocationBitArrayType | |
DataType | |
ElementType | |
FElementOrFreeListLink | The element type stored is only indirectly related to the element type requested, to avoid instantiating TArray redundantly for compatible types. |
TRangedForConstIterator | |
TRangedForIterator |
Deprecated Functions
Type | Name | Description | |
---|---|---|---|
![]() |
int32 | AddAtLowestFreeIndex
(
const ElementType& Element, |
AddAtLowestFreeIndex API is deprecated; please use EmplaceAtLowestFreeIndex instead. |