I've setup a std map to map some numbers, at this point I know what numbers I'm mapping from an to, eg:
std::map<int, int> myMap;
map[1] = 2;
map[2] = 4;
map[3] = 6;
Later however, I want to map some numbers to the lowest number possilbe that is not in the map, eg:
map[4] = getLowestFreeNumberToMapTo(map); // I'd like this to return 1
map[5] = getLowestFreeNumberToMapTo(map); // I'd like this to return 3
Any easy way of doing this?
I considered building an ordered list of numbers as I added them to the map so I could just look for 1, not find it, use it, add it etc.