C++ a map to a 2 dimensional vector
- by user1701545
I want to create a C++ map where key is, say, int and value is a 2-D vector of double:
map myMap;
suppose I filled it and now I would like to update the second vector mapped by each key (for example divide each element by 2). How would I access that vector iteratively?
The "itr-second[0]" syntax in the statement below is obviously wrong. What would be the right syntax for that action?
for(std::map<in, vector<vector<double> > > itr = myMap.begin(); itr != myMap.end();++itr)
{
for(int i = 0;i < itr->second[0].size();++i)
{
itr->second[0][i] /= 2;
}
}
thanks,
rubi