I have declared,
map<int, vector<int>> abcmap;
map<int,vector<int>>:: iterator itmap;
vector<int>SPLINKS;
SPLINKS contains:
1 3 4
abcmap contains;
1=> 1
2=> 2 6
3=> 1 2 4
I want to iterate both SPLINKS and abcmap to find and erase elements that do not match in both containers;
ie after execution;
2=>2 6 //not matched with either 1 or 3 or 4
I write something like;
for(itmap = abcmap.begin(); itmap != abcmap.end(); ++itmap)
{
cout << endl << itmap->first <<" => ";
for(size_t n=0; n<(*itmap).second.size(); n++)
{
for(itspl=SPLINKS.begin(); itspl!=SPLINKS.end(); ++itspl)
{
if((*itspl)==itmap->second[n])
{
abcmap.erase(itmap);
}
}
}
}
But I get debug assertion failed! in both cases.
Can anyone say how to overcome this problem?