FEntitySlotMap
EntityID → World slot: open addressing with linear probing over a power-of-two table kept at most half full. std::unordered_map paid a node allocation per entity and a pointer chase per lookup; an entity id is a random 64-bit UUID, so here a lookup is almost always one probe into a flat array. Erase shifts the rest of the probe run back instead of leaving a tombstone, so a world that churns entities for hours never ends up probing over dead buckets.
- Module
- ECS
- Header
#include "ECS/EntitySlotMap.h"- Namespace
Mowo
Concurrent Find calls are fine; every write is a World structural operation and runs under the World's mutex.
Public functions
| Returns | Name | Description |
|---|---|---|
uint32_t | Find | |
bool | Contains | |
uint32_t& | FindOrAdd | The value stored for id, inserting value first when it is absent. |
bool | Erase | |
size_t | Size | |
void | Clear | Keeps the table's capacity: a world that is cleared is usually refilled with as many entities. |
size_t | BucketCount |
Function details
Find
uint32_t Find(EntityID id) constContains
bool Contains(EntityID id) constFindOrAdd
uint32_t& FindOrAdd(EntityID id, uint32_t value, bool& inserted)The value stored for id, inserting value first when it is absent. The reference stays valid until the next FindOrAdd, Erase or Clear.
Erase
bool Erase(EntityID id)Size
size_t Size() constClear
void Clear()Keeps the table's capacity: a world that is cleared is usually refilled with as many entities.
BucketCount
size_t BucketCount() const