IT lexicon › Programming › Generational index

Generational index

Programming På svenska → Updated: 2026-10-25

A reference that packs an array index together with a generation counter, so an old handle pointing at a reused slot can be detected as invalid.

When an object is destroyed its array slot is freed but not moved; the next object reuses the slot and increments its generation by one. A handle carries both the index and the generation it was issued under. On dereference the handle's generation is compared with the slot's current one — if they differ the original object is gone, turning an otherwise dangerous dangling pointer into a cheap, detectable miss.

This gives stable O(1) references without reference counting or a garbage collector, which is why ECS frameworks such as EnTT and Bevy use it for entity IDs, and why slot-map containers are built on it. Its usual companion is a sparse set that records where the live slots actually sit.

← Back to the lexicon