Navigation
API > API/Runtime > API/Runtime/GeometryCore
TSparseListSet stores a sparse set of indexed variable-size lists. This is useful in cases where many relatively small lists that have a 1-1 correspondence with a bounded index space are needed, eg for per-vertex lists for a mesh, per-cell lists for an octree, etc.
The interface is compatible with FSmallListSet, which may be more effective for very small lists (optimized for ~8 elements), but does not scale very well to larger lists (10s-to-100s).
Internally, TSparseListSet uses a strategy where the small lists are stored in sequences of fixed-size blocks, similar to FDynamicVector, but the block size is configurable. The blocks are allocated from larger "chunks" of blocks (also of configurable size). These parameters can be set on construction to values appropriate for particular use cases.
TSparseListSet can support parallel insertion into the lists. Note however that lists cannot be added (via AllocateAt) while parallel insertion occurs via Insert(Index). To allow for this type of usage, AllocateAt() returns a FListHandle which can then be used with Insert() or SetValues() even while other AllocateAt() calls occur (within a lock).
| Name | TSparseListSet |
| Type | struct |
| Header File | /Engine/Source/Runtime/GeometryCore/Public/Util/SparseListSet.h |
| Include Path | #include "Util/SparseListSet.h" |
Syntax
template<typename ElementType>
struct TSparseListSet
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Util/SparseListSet.h | |||
TSparseListSet
(
int BlockSizeIn, |
Util/SparseListSet.h |
Structs
| Name | Remarks |
|---|---|
| FChunk | Large block of memory from which smaller blocks are allocated |
| FList | |
| FListHandle | Handle to an allocated list returned by AllocateAt() |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AllocationLock | FCriticalSection | Util/SparseListSet.h | ||
| BlockSize | int | Size of a list memory block, ie lists are allocated in blocks of this size, so also the minimum size (in memory) of a list even if it has 0 elements | Util/SparseListSet.h | |
| BlocksPerChunk | int | Number of memory blocks in a "chunk", chunks are allocated as needed, so minimum size of a TSparseListSet is (BlocksPerChunk * BlockSize * sizeof(ElementType)) | Util/SparseListSet.h | |
| ChunkList | TArray< TUniquePtr< FChunk > > | Util/SparseListSet.h | ||
| FreeList | TArray< ElementType * > | Util/SparseListSet.h | ||
| Lists | TDynamicVector< FList > | Util/SparseListSet.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FListHandle AllocateAt
(
int32 ListIndex |
Create a list at the given ListIndex | Util/SparseListSet.h | |
void Clear
(
int32 ListIndex |
Remove all elements from the list at ListIndex | Util/SparseListSet.h | |
bool Contains
(
int32 ListIndex, |
Search for the given Value in list at ListIndex | Util/SparseListSet.h | |
void Enumerate
(
int32 ListIndex, |
Call ApplyFunc on each element of the list at ListIndex | Util/SparseListSet.h | |
bool EnumerateEarlyOut
(
int32 ListIndex, |
Call ApplyFunc on each element of the list at ListIndex, until ApplyFunc returns false | Util/SparseListSet.h | |
int32 GetCount
(
int32 ListIndex |
Util/SparseListSet.h | ||
void Insert
(
FListHandle ListHandle, |
Insert Value into List identified by ListHandle | Util/SparseListSet.h | |
void Insert
(
int32 ListIndex, |
Insert Value into List at ListIndex | Util/SparseListSet.h | |
bool IsAllocated
(
int32 ListIndex |
Util/SparseListSet.h | ||
bool Remove
(
int32 ListIndex, |
Remove first occurrence of Value from the list at ListIndex | Util/SparseListSet.h | |
| Set the values of the List at ListIndex | Util/SparseListSet.h | ||
void SetValues
(
FListHandle ListHandle, |
Set the values of the List identified by ListHandle | Util/SparseListSet.h |