Please consider the following situation:
using namespace std;
unordered_map<int, vector<A>> elements;
Now I'm iterating over this unordered map:
for (auto it = elements.begin(); it != elements.end(); ++it)
Inside the loop, I'm forming clusters out of several elements of elements
(the current one that it
points to and some more, not necessarily those next in line!). Because each element can be only part of one cluster, I'd like to remove those from the map and then continue with the next element (i.e., build the next cluster).
How can I do this and still continue the iteration at the correct position?