主要是在利用erase删除,遍历的处理
std::map<int ,string > test;
std::map<int, std::string>::iterator it =test.begin();
for(it ; it != test.end() ; )
{
if(*it == 0) =>条件可以自己设置
{
it = test.erase(it); =>将删除后的指针重新指向it
}
else
{
it++; =>删除则直接++
}
}
可以避免删除过程中遍历不全或者重复遍历的情况