C++: Best Way To Hold Entity List vector vs set -


this question has answer here:

i have implemented entity-component system manage entities in game engine, managing components using std::map. main part hold entities in cworld class. entities can directly accessed index cworld, add component etc. , also, entities iterated each tick update , render operations. , list not static can guess, mean entities can die, need removed list @ point. @ point, need ask differences between std::vector , set, or suggestion hold entities.

if want access elements index, , if old elements may die such range of active indices may contain gaps, map easiest solution. map allows iterate , remove single entities easily.

list easy remove single entity hard look-up specific entity index.

vector difficult remove single entity without leaving gaps. plugging gap, index of entities after removal change.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -