map删除迭代器的处理

简介: map删除迭代器的处理

删除部分:

std::map<inti,int> targets;
for(auto it = targets.begin(); it!=targets.end();)
{
    if(......)
    {
        targets.erase(it++);
    }
    else
    {
    it++;
    }
}

全部删除:

std::map<inti,int> targets;
for(auto it = targets.begin(); it!=targets.end();)
{
  it = targets.erase(it);
}
相关文章
|
21天前
Collection和Map的遍历方式
Collection和Map的遍历方式
12 0
|
21天前
|
测试技术
你知道几种遍历map的方式?
你知道几种遍历map的方式?
|
21天前
|
C++
c++ unordered_map4种遍历方式
c++ unordered_map4种遍历方式
67 0
|
11月前
List,Map 三种遍历方式:(总结理解)
List,Map 三种遍历方式:(总结理解)
46 0
|
11月前
遍历 ArrayList和遍历 Map的几种方式
遍历 ArrayList和遍历 Map的几种方式
47 0
|
编译器
遍历Map的六种方式
遍历Map的六种方式
152 0
遍历Map的六种方式
|
Java 容器
使用Iterator遍历map以及list用法
使用Iterator遍历map以及list用法
143 0
使用Iterator遍历map以及list用法
Map的遍历方式
Map的遍历方式
119 0
遍历Map的三种方式
遍历Map的三种方式
146 0

热门文章

最新文章