class ecs::TSparseSet

template<SparseSetDeletePolicy DeletePolicy>
Inherits: SparseSet

Implements features of SparseSet that depend on a particular deletion policy.

Public

Constructors

TSparseSet<DeletePolicy>

TSparseSet<DeletePolicy>()

TSparseSet<DeletePolicy>

TSparseSet<DeletePolicy>(TypeHash elementTypeHash)

Methods

~TSparseSet<DeletePolicy>

~TSparseSet<DeletePolicy>() override = default

Clear

void Clear() override

Removes everything from the set and clears the internal arrays.

ClearInvalid

void ClearInvalid() override

Removes all invalid entities from the set.

Only relevant for sets using in-place deletion policy.

Swap

void Swap(Entity lhs, Entity rhs) override

Swaps the location of the provided entities in the packed array, as well as the relevant payload (data associated with the entities), if any.

GetDeletePolicy

SparseSetDeletePolicy GetDeletePolicy() const override

Returns the current delete policy.

GetFirstFreeElementPackedIndex

u64 GetFirstFreeElementPackedIndex() const override

When using in-place deletion policy returns the packed index to the first invalid element.

When using swap-only deletion policy returns the number of valid entities in the set. Not relevant if using swap-and-erase deletion policy.

Protected

Methods

AddInternal

Iterator AddInternal(Entity entity, bool forceAddAtEnd) override

Adds a new entity to the set.

entity
Entity to add.
forceAddAtEnd
Only relevant when using in-place deletion policy. When true it will add an entity at the end of the packaged data array, rather than re-using the first available invalid entity entry.

Returns: Iterator to the added entity.

EraseInternal

void EraseInternal(Entity entity) override

Removed an entity from the sparse set.

Entity must be a part of the sparse set.

ClearInternal

void ClearInternal()

Same as SparseSet::ClearInternal but also resets the free list head.

Private

Methods

MoveOrSwapPayload

void MoveOrSwapPayload(u64, u64)

Default implementation that doesn't do anything as there is no payload to move.

Fields

mFreeListHead

u64 mFreeListHead

For in-place delete policy points to first free entry, or kMaximumEntryCount if no free entries.

For swap-only delete policy points to the first free entry, where all other elements are sequentially following the first free element. This value corresponds to valid entry count. For swap-and-erase delete policy this value is not used.