TSparseArray

Forward declarations.

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

Name Description

Public variable

*: Add(A) ...

 

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.

Public variable

Free list is

 

now

Destructors

Name Description

Public function

~TSparseArray()

Destructor.

Functions

Name Description

Public function

 

Add

(
    B
)

Public function

int32

 

Add

(
    ElementType&& Element
)

Adds an element to the array.

Public function

int32

 

Add

(
    const ElementType& Element
)

Adds an element to the array.

Public function

FSparseArray...

 

AddUninitialized()

Allocates space for an element in the array.

Public function

FSparseArray...

 

AddUninitializedAtLowestFreeIndex

(
    int32& LowestFreeIndexSearchStart
)

Public function

FSparseArray...

 

AllocateIndex

(
    int32 Index
)

Marks an index as allocated, and returns information about the allocation.

Public function Static

void

 

AppendHash

(
    const FPlatformTypeLayoutParameters...,
    FSHA1& Hasher
)

Public function Const

FORCEINLINET...

 

begin()

Public function

FORCEINLINET...

 

begin()

DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.

Public function

bool

 

Compact()

Compacts the allocated elements into a contiguous index range.

Public function

bool

 

CompactStable()

Compacts the allocated elements into a contiguous index range.

Public function Const

void

 

CopyUnfrozen

(
    const FMemoryUnfreezeContent& Cont...,
    void* Dst
)

Public function Const

TConstIterat...

 

CreateConstIterator()

Creates a const iterator for the contents of this array

Public function

TIterator

 

CreateIterator()

Creates an iterator for the contents of this array

Public function

int32

 

Emplace

(
    ArgsType&&... Args
)

Constructs a new item at the last freed index of the array.

Public function

int32

 

EmplaceAt

(
    int32 Index,
    ArgsType&&... Args
)

Constructs a new item at a given index of the array.

Public function

int32

 

EmplaceAtLowestFreeIndex

(
    int32& LowestFreeIndexSearchStart,
    ArgsType&&... Args
)

Constructs a new item at the lowest free index of the array.

Public function

void

 

Empty

(
    int32 ExpectedNumElements
)

Removes all elements from the array, potentially leaving space allocated for an expected number of elements about to be added.

Public function Const

FORCEINLINET...

 

end()

Public function

FORCEINLINET...

 

end()

Public function

void

 

Insert

(
    int32 Index,
    typename TTypeTraits< ElementType >...
)

Inserts an element to the array.

Public function

FSparseArray...

 

InsertUninitialized

(
    int32 Index
)

Allocates space for an element in the array at a given index.

Public function

 

Remove

(
    B
)

Public function

 

Remove

(
    A
)

Public function

void

 

RemoveAt

(
    int32 Index,
    int32 Count
)

Removes Count elements from the array, starting from Index.

Public function

void

 

RemoveAtUninitialized

(
    int32 Index,
    int32 Count
)

Removes Count elements from the array, starting from Index, without destructing them.

Public function

void

 

Reserve

(
    int32 ExpectedNumElements
)

Preallocates enough memory to contain the specified number of elements.

Public function

void

 

Reset()

Empties the array, but keep its allocated memory as slack.

Public function

void

 

Shrink()

Shrinks the array's storage to avoid slack.

Public function

void

 

Sort()

Sorts the elements assuming < operator is defined for ElementType.

Public function

void

 

Sort

(
    const PREDICATE_CLASS& Predicate
)

Sorts the elements using the provided comparison class.

Public function

void

 

StableSort()

Stable sorts the elements assuming < operator is defined for ElementType.

Public function

void

 

StableSort

(
    const PREDICATE_CLASS& Predicate
)

Stable sorts the elements using the provided comparison class.

Public function Const

void

 

WriteMemoryImage

(
    FMemoryImageWriter& Writer
)

Operators

Name Description

Public function

TSparseArray...

 

operator+=

(
    const TArray< ElementType >& Other...
)

Public function

TSparseArray...

 

operator+=

(
    const TSparseArray& OtherArray
)

Concatenation operators

Classes

Name

Description

Public class

TConstIterator

Iterates over all allocated elements in a const sparse array.

Public class

TConstSubsetIterator

An iterator which only iterates over the elements of the array which correspond to set bits in a separate bit array.

Public class

TIterator

Iterates over all allocated elements in a sparse array.

Public class

TRangedForConstIterator

Public class

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

Name Description

Public function

int32

 

AddAtLowestFreeIndex

(
    const ElementType& Element,
    int32& LowestFreeIndexSearchStart
)

AddAtLowestFreeIndex API is deprecated; please use EmplaceAtLowestFreeIndex instead.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Cancel