class
ecs::TComponentSparseSet
template<typename ComponentType, bool InPlaceDelete = false, u64 PackedPageSize = 1024>Storage used for storing components associated with entities.
Template parameters
ComponentType | |
|---|---|
InPlaceDelete | If true, deletion of entities will not erase the entity, but rather just mark it as invalid. Space of invalid entities can be re-used, but iterating such storages is slower. Additionally sorting operations are limited when invalid entities are present in the storage. |
PackedPageSize | Size of a single payload page. In order to reduce the impact of array resize, payload array is split into pages of this size. |
Public
Constructors
TComponentSparseSet<ComponentType, InPlaceDelete, PackedPageSize>
Methods
~TComponentSparseSet<ComponentType, InPlaceDelete, PackedPageSize>
Get
Returns the component value for the specified entity.
Caller must ensure storage contains the entity.
Get
Returns the component value for the specified entity.
Caller must ensure storage contains the entity.
Clear
Removes everything from the set and clears the internal arrays.
ClearInvalid
Removes all invalid entities from the set.
Only relevant for sets using in-place deletion policy.
Swap
Swaps the location of the provided entities in the packed array, as well as the relevant payload (data associated with the entities), if any.
Reserve
Reserves internal memory in order to fit entries.
Capacity
Returns how many entries can fit into the internal memory.
Shrink
Shrinks the memory use of the set to accomodate the currently assigned entries, without any reserve for new entries.
Each
Allows easy iteration over all components using a range for loop.
Each
ReverseEach
Allows easy iteration over all components using a range for loop, in reverse order.
ReverseEach
Cbegin
Iterator to the first component in the storage.
Begin
Begin
Cend
Iterator past the last component in the storage.
End
End
Crbegin
Iterator to the last component in the storage, for reverse iteration.
Rbegin
Rbegin
Crend
Iterator to before the first component in the storage, for reverse iteration.
Rend
Rend
cbegin
begin
begin
cend
end
end
crbegin
rbegin
rbegin
crend
rend
rend
~TSparseSet<DeletePolicy>
GetDeletePolicy
Returns the current delete policy.
GetFirstFreeElementPackedIndex
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
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.
ClearInternal
Same as SparseSet::ClearInternal but also resets the free list head.
Private
Methods
EraseInternal
Removed an entity from the sparse set.
Entity must be a part of the sparse set.
MoveOrSwapPayload
Moves the component from to .
ShrinkComponentArray
Destroys any excess pages, as long as the internal contain can fit .
GetOrCreateComponentPageFor
Returns a page in which to store the component with the specified index at.
Internally allocates a page for the provided index if one doesn't exist.
GetOrCreateComponentPointer
Returns a pointer to store the component with the specified index at.
Internally allocates a page for the provided index if one doesn't exist.
GetComponentReference
Returns a reference to store the component with the specified index at.
Internally allocates a page for the provided index if one doesn't exist.
GetComponentReference
Returns a reference to store the component with the specified index at.
Internally allocates a page for the provided index if one doesn't exist.
staticGetComponentIndexWithinPage
Converts a global packed component index, into an index that's local to the page.
staticGetComponentPage
Converts a global packed component index, into a page index.