I'm implementing an Entity-Component-System library based on simple dense array approach (using huge arrays for every component field with the size equal to the number of entities, where array[entity] = field value). I also want an index akin to relational databases, i.e. an additional data structure allowing to quickly (in O(1) or at least O(log N)) answer the question "which entity (or entities) has this exact value of this field in this component?" I've implemented it using homebrew open-hashed hashtable, but I'm afraid it is way too unfriendly to CPU cache (since value hashing is pretty much random). What are some options of such data structures which are more cache-friendly?
parent" field allows every entity to know its parent, but also having an index one could quickly get the list of children for given parent) and yes, position hashing (calculating the tile number fromx,yvalues in position component and storing it in indexed field would allow to quickly get all of the enitites residing in the given map tile). \$\endgroup\$