![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <SparseArray.h>
Inheritance diagram for TSparseArrayBase< SizeOfElementType, AlignOfElementType, Allocator >:Protected Types | |
| typedef TSparseArrayElementOrFreeListLink< TAlignedBytes< SizeOfElementType, AlignOfElementType > > | FElementOrFreeListLink |
| typedef TArray< FElementOrFreeListLink, typename Allocator::ElementAllocator > | DataType |
| typedef TBitArray< typename Allocator::BitArrayAllocator > | AllocationBitArrayType |
Protected Member Functions | |
| TSparseArrayBase (FIntrusiveUnsetOptionalState Tag) | |
| constexpr | TSparseArrayBase () |
| consteval | TSparseArrayBase (EConstEval) |
| TSparseArrayBase (const TSparseArrayBase &InCopy) | |
| FSparseArrayAllocationInfo | AllocateIndex (int32 Index) |
| FSparseArrayAllocationInfo | AddUninitialized () |
| FSparseArrayAllocationInfo | AddUninitializedAtLowestFreeIndex (int32 &LowestFreeIndexSearchStart) |
| void | RemoveAtUninitialized (int32 Index, int32 Count=1) |
| void | Reserve (int32 ExpectedNumElements) |
| void | Shrink () |
| void | SortFreeList () |
| FSparseArrayAllocationInfo | InsertUninitialized (int32 Index) |
| bool | Compact () |
| int32 | GetMaxIndex () const |
| bool | IsEmpty () const |
| int32 | Num () const |
| int32 | Max () const |
| bool | IsValidIndex (int32 Index) const |
| bool | IsAllocated (int32 Index) const |
Protected Attributes | |
| DataType | Data |
| AllocationBitArrayType | AllocationFlags |
| int32 | FirstFreeIndex = -1 |
| int32 | NumFreeIndices = 0 |
|
protected |
|
protected |
|
protected |
The element type stored is only indirectly related to the element type requested, to avoid instantiating TArray redundantly for compatible types.
|
inlineexplicitprotected |
|
inlineconstexprprotected |
Default constructor.
|
inlineexplicitprotected |
Explicitly consteval constructor.
|
inlineprotected |
Copy constructor.
|
inlineprotected |
Allocates space for an element in the array. The element is not initialized, and you must use the corresponding placement new operator to construct the element in the allocated memory.
|
inlineprotected |
|
inlineprotected |
Marks an index as allocated, and returns information about the allocation.
|
inlineprotected |
Compacts the allocated elements into a contiguous index range. Returns true if any elements were relocated, false otherwise.
|
inlineprotected |
|
inlineprotected |
Allocates space for an element in the array at a given index. The element is not initialized, and you must use the corresponding placement new operator to construct the element in the allocated memory.
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
|
inlineprotected |
Removes Count elements from the array, starting from Index, without destructing them.
|
inlineprotected |
Preallocates enough memory to contain the specified number of elements.
| ExpectedNumElements | the total number of elements that the array will have |
|
inlineprotected |
Shrinks the array's storage to avoid slack.
|
inlineprotected |
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. This also means that assigned indices no longer depend on the order in which old items were removed, making it easier to use the container when determinism is required (without a container reset).
E.g., call SortFreeList() each frame to make the container assign the same indices when we perform the following operations: Frame1: Add(A) -> [0]; Add(B) -> [1]; Remove(A); Remove(B); (Free list is now {[1],[0],...}) Frame2: Add(A) -> [1]; Add(B) -> [0]; Remove(A); Remove(B); (Free list is now {[0],[1],...})
NOTE: This is operation is currently O(N) with N = GetMaxIndex(). This could be improved for large mostly-full arrays if necessary.
|
protected |
|
protected |
|
protected |
The index of an unallocated element in the array that currently contains the head of the linked list of free elements.
|
protected |
The number of elements in the free list.