class ecs::EntitySparseSet

Storage used for storing only entities.

Provides helper functionality to create new unique entities.

Public

Constructors

EntitySparseSet

EntitySparseSet()

Methods

~EntitySparseSet

~EntitySparseSet() noexcept override = default

Create

Entity Create()

Creates a brand new entity with a unique identifier.

Create

Entity Create(Entity hint)

Creates a new entity while attempting to re-use an invalid entity identifier as provided by .

Clear

void Clear() override

Removes everything from the set and clears the internal arrays.

Each

IteratorRange Each()

Allows easy iteration over all components using a range for loop.

Each

ConstIteratorRange Each() const

ReverseEach

ReverseIteratorRange ReverseEach()

Allows easy iteration over all components using a range for loop, in reverse order.

ReverseEach

ConstReverseIteratorRange ReverseEach() const

~TSparseSet<DeletePolicy>

~TSparseSet<DeletePolicy>() override = default

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

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

AddInternal

UnderlyingIterator AddInternal(Entity hint, bool forceAddAtEnd) override

Adds a new entity to the set.

hint
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.

CreateEntity

Entity CreateEntity()

Creates a new entity with a unique index, and increments the next index to assign.

Fields

mNextEntityId

Entity::IdentifierType mNextEntityId