I am not sure, if this is the right place to post this question. Please let me know if it's not.
I have got a number of 'entities'. Each entity has a number of attributes(all entities have same number of attributes) which are themselves stored as arrays (of same length). I would like store the 'entities' in such a manner, so that I can fetch each entity by name.
To do this I should probably use a map<string, entity>
to store each entity by name.
Now the trouble is, before this requirement (to store multiple entities) came up, I used to store an entity as a map<string, vector>
where each vector is an attribute and the string denotes the attribute name.
Taking this into account map<string, entity>
now becomes:map<string, map<string, vector>
What was previously a simple and elegant solution has become difficult to read and awkward to use.
Encapsulating the
map<string, vector>
as an entity class seems like going too far for the sake of beautiful code (as I don't have any procedures to put in the class).Would I be better off using entity as a struct to "beautify" the code?
Or is there a much more simple or more elegant solution that I'm missing?
Or is this implementation the best I can hope for?
Note: I am dealing with a fairly large data set. There will be 1500-2000 entities in the map. Each entity will have 4-10 attributes. Each attribute will have close to 10000 values. Performance is a constraint.