I ve been trying all night, and talk of maps, arrays, vectors and hash_maps have filled my head. im just confused now. i posted a previous question here: C++ map really slow?
problem was fixed but it seems map s are still not fast enough. i need to keep adding data. data is added ALOT during run time. i got it all working now, and if i add 1 piece of data per step (per frame in the game) it works fine. but once i do 2 at a time, i see performance drops. i looked into this hash stuff but couldn t find alot on it. just an fyi, the number of items stores will probably never exceed 2000~ or so. so i guess it is fairly small scaled..
what im trying to store, as someone else put it, is this: "object with id 101 has a value of 4 for setting 1" or information[101][1] = 4; except that i just keep getting more and more objects (differet id s, which is the key value) added into the system with different settings (2nd key). - i dont know what the size of the array will be (thats why i didnt use arrays). looked into vectors but that confused the hell out of me. >_<
right now i have:
//declared as a class member
map<double, map<int, double> > objIdMap;
//// lower down the page, in some function
map<int, double> objSettingsMap;
objSettingsMap[0] = value;
objSettingsMap[1] = value;
objSettingsMap[2] = value;
objSettingsMap[3] = value;
objIdMap[id] = objSettingsMap;
return(1);
or maybe it isnt the map s? is it normal for maps to perform slow like this when they re used so heavily? (i havnt included it in the code above, but on every step of the game every object with an id in objIdMap is accessing it to retrieve their objSettingsMap values. though the slow downs only occur when the above is executed more than once per step)..
so yea, what do you guys think is the best way to hold this data, and retrieve it etc? please provide example :( thanks