class

TEntityHandleMap

Per-entity data kept by the entity's World slot instead of by hashing its 64-bit id: a lookup is the world's slot index plus one array read, and a walk is a linear pass over a dense vector. A cell remembers the id it was written for, so a slot the world recycled for a new entity never answers for the old one; Prune drops the cells of entities that no longer exist.

Module
ECS
Header
#include "ECS/EntityHandleMap.h"
Namespace
Mowo
Template
template<typename V, bool StableAddresses = false>

The slot comes from World::GetSlotHint, which is one hash probe in the world's own table — it is still cheaper than std::unordered_map's node chase, and a caller that already holds a hint passes it to skip the probe. StableAddresses keeps the cells in a deque, whose growth never moves a cell already stored: an API that hands out a pointer into per-entity state (a perceiver's known-actor list, a resident's search points) stays valid while later entities add their own cells. The default vector storage reallocates on growth, so a pointer into it dies the moment another entity is first seen.

Public functions

ReturnsNameDescription
V*Find
const V*Find
V*FindAt
V*FindOrAddThe value for id, default-constructed when absent.
boolEraseA destroyed entity has no slot to look up, so its cell is found by a scan: callers erase an id that may already be dead (a claim being cleaned up after its owner), and that must not leave the cell behind.
size_tPruneDrops every cell whose entity is gone, or whose slot now holds another.
voidForEachEraseCalls fn(EntityID, V&) for every live cell; fn returns true to erase it.
voidForEach
voidForEach
size_tSize
voidClear

Function details

Find

C++
V* Find(const World& world, EntityID id)

Find

C++
const V* Find(const World& world, EntityID id) const

FindAt

C++
V* FindAt(uint32_t slot, EntityID id)

FindOrAdd

C++
V* FindOrAdd(const World& world, EntityID id)

The value for id, default-constructed when absent. False from the entity not existing in world is reported as a null result.

Erase

C++
bool Erase(const World& world, EntityID id)

A destroyed entity has no slot to look up, so its cell is found by a scan: callers erase an id that may already be dead (a claim being cleaned up after its owner), and that must not leave the cell behind.

Prune

C++
size_t Prune(const World& world)

Drops every cell whose entity is gone, or whose slot now holds another.

ForEachErase

C++
template<typename Fn> void ForEachErase(Fn&& fn)

Calls fn(EntityID, V&) for every live cell; fn returns true to erase it.

ForEach

C++
template<typename Fn> void ForEach(Fn&& fn)

ForEach

C++
template<typename Fn> void ForEach(Fn&& fn) const

Size

C++
size_t Size() const

Clear

C++
void Clear()
Generated from ECS/EntityHandleMap.h via ecs.json · Dec 5, 2026Version 1.1.0