I\'m working on a data-oriented entity component system where component types and system signatures are known at compile-time.
An entity>
Having a sparse integer set per signature type is the theoretically best solution (in terms of time complexity).
The sparse integer set data structure allows efficient contiguous O(N)
iteration over the stored integers, O(1)
insertion/removal of integers, and O(1)
querying for a specific integer.
The per-signature sparse integer set would store all entity IDs associated with that specific signature.
Example: Diana, an open-source C and C++ ECS library, makes use of sparse integer set to keep track of entities in systems. Every system has its own sparse integer set instance.