I set the std card to display some numbers, at this point I know which numbers I map to, for example:
std::map<int, int> myMap;
map[1] = 2;
map[2] = 4;
map[3] = 6;
Later, however, I want to match some numbers with the lowest number that is possibly not on the map, for example:
map[4] = getLowestFreeNumberToMapTo(map);
map[5] = getLowestFreeNumberToMapTo(map);
Any easy way to do this?
I was thinking of creating an ordered list of numbers when I added them to the map so that I could just search for 1 and not find it, use it, add it, etc.
source
share