I'm just looking at the fastest way to finish this problem. This will give me a good start.
|
this honestly looks like homework given the small amount of data you are looking at. The fastest answer isn't worth it, you will be fine with a decent answer.
The fastest way depends on details. Just a few of the more basic questions would be..
-how much data do you expect? (you answered this one, its not much).
-how do you need to access it most often? (by index at random?)
-is it very volatile (tons of adds and deletes) or nearly static (load and rarely change)?
- do you need to keep it in any kind of order (say by age?)
To me this looks like a 1-d problem. why do you have 2 indices into your data, what are those, and can you knock that down to ONE??
consider:
struct
{
int age; //could also be a birth date
double waist;
};
vector<age> alldappl(160000); //its ok if the size is too small, it can grow later,
//but give it a ballpark best guess
cout << alldappl[index].age; //but what is index ? is it part of the data like their SSN?
if index is from the data then an unordered map<> might be better. If its 0-159999 then this is fine. 400x400 can be directly converted into 0-159999 or you can use a 2d array if you want.