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).
Constructors
| Type | Name | Description | |
|---|---|---|---|
TSparseArray () |
Default constructor. | ||
TSparseArray
(
TSparseArray&& InCopy |
Move constructor. | ||
TSparseArray
(
const TSparseArray& InCopy |
Copy constructor. |
Destructors
| Type | Name | Description | |
|---|---|---|---|
| Destructor. |
Functions
| Type | Name | Description | |
|---|---|---|---|
| int32 | Add
(
ElementType&& Element |
Adds an element to the array. | |
| int32 | Add
(
const ElementType& Element |
Adds an element to the array. | |
| int32 | AddAtLowestFreeIndex
(
const ElementType& Element, |
Add an element at the lowest free index, instead of the last freed index. | |
| FSparseArrayAllocationInfo | Allocates space for an element in the array. | ||
| FSparseArrayAllocationInfo | AddUninitializedAtLowestFreeIndex
(
int32& LowestFreeIndexSearchStart |
||
| FSparseArrayAllocationInfo | AllocateIndex
(
int32 Index |
End - intrusive TOptional |
|
| void | AppendHash
(
const FPlatformTypeLayoutParameters& LayoutParams, |
||
| TRangedForIterator | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | |
| TRangedForConstIterator | begin () |
||
| void | CheckAddress
(
const ElementType* Addr |
Checks that the specified address is not part of an element within the container. | |
| 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, |
||
| void | CountBytes
(
FArchive& Ar |
Tracks the container's memory use through an archive. | |
| 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 | 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 | Removes all elements from the array, potentially leaving space allocated for an expected number of elements about to be added. | ||
| TRangedForConstIterator | end () |
||
| TRangedForIterator | end () |
||
| int32 | Finds the index of an arbitrary element. | ||
| SIZE_T | Helper function to return the amount of memory allocated by this container Only returns the size of allocations made directly by the container, not the elements themselves. | ||
| int32 | GetMaxIndex () |
||
| int32 | IndexOfByPredicate
(
Predicate Pred |
Finds an item by predicate. | |
| 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. | |
| bool | IsAllocated
(
int32 Index |
||
| bool | IsCompact () |
||
| bool | IsEmpty () |
||
| bool | IsValidIndex
(
int32 Index |
||
| int32 | Num () |
||
| int32 | PointerToIndex
(
const ElementType* Ptr |
||
| void | 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 | 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 | SortFreeList () |
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. | |
| 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 | |
|---|---|---|---|
| bool | operator!=
(
const TSparseArray& B |
Inequality comparison operator. | |
| const ElementType & | operator[]
(
int32 Index |
||
| ElementType & | operator[]
(
int32 Index |
Accessors. | |
| TSparseArray & | operator+=
(
const TArray< ElementType >& OtherArray |
||
| TSparseArray & | operator+=
(
const TSparseArray& OtherArray |
Concatenation operators | |
| TSparseArray & | operator=
(
const TSparseArray& InCopy |
Copy assignment operator. | |
| TSparseArray & | operator=
(
TSparseArray&& InCopy |
Move assignment operator. | |
| bool | operator==
(
const TSparseArray& B |
Equality comparison operator. | |
| bool |
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. |
| IntrusiveUnsetOptionalStateType |
Constants
| Name | Description |
|---|---|
| bHasIntrusiveUnsetOptionalState | Start - intrusive TOptional |