But I am not able to use "find" for the inner map to search for "y".
Is there any way I can use "find" to search the integer "y" without using an additional map for the inner key-value pair (int-double in my case)?
Thanks Keskiverto.
I tried like how you mentioned as below, but it is searching the whole pair of (x, y):
1 2 3
myMap.insert(std::make_pair(std::make_pair(x, y), z));
auto elem = myMap.find(std::make_pair(x, y));
But I want to find first int (x), if it is available, find the next int (y), if that is available then update the value of the double (z). If int (y) is not found then insert (y, z) into the map.
If x is not available then insert (x,y,z) into the map.
Something like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
if (myMap.find(x) = true)
{
if (myMap.find(y) = true)
{
update z;
}
else
{
insert (y, z);
}
}
else
{
insert (x, y, z);
}
Thanks Gunnerfunner. I am struggling to find the next int in the inner pair (2 or 6 in the example you have showed). How can I find it?
But I want to find first int (x), if it is available, find the next int (y), if that is available then update the value of the double (z). If int (y) is not found then insert (y, z) into the map.