vector :

iter = container.erase(iter);    //erase的返回值是删除元素下一个元素的迭代器

vector<int>::iterator it = a.begin();
for(;it !=a.end();)
{
printf("%d\n",*it);
it = a.erase(it);
}

map:

dataMap.erase(iter++)

注:map erase 没有返回下一个迭代器的方法

#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
using namespace std; int main(int argc, char *argv[])
{
vector<int>a;
a.push_back();
a.push_back();
a.push_back();
a.push_back();
vector<int>::iterator it = a.begin();
for(;it !=a.end();)
{
printf("%d\n",*it);
it=a.erase(it);
}
map<int,int>b;
b[]=;
b[]=;
b[]=;
b[]=;
map<int,int>::iterator it1 = b.begin();
for(;it1!=b.end();)
{
printf("%d\n",it1->first);
b.erase(it1++);
} }

最新文章

  1. sql语句修改字段长度
  2. Emacs-24.1 + ECB-2.40 + cscope-15.7a + cedet 无root权限指定目录安装与配置
  3. vs---错误收集并自己解决后归纳
  4. 移动端调试工具推荐 小苹果和debugap
  5. esc设置多站点 域名解析
  6. JDBC和JPA调用储存过程 接收存储过程有返回值
  7. Matlab中plot、fplot、ezplot的使用方法和区别
  8. 【Xamarin开发 Android 系列 6】 Android 结构基础(上)
  9. 排序 O(nlogn)
  10. PND_白盾
  11. 从汇编看c++内联函数评估求值
  12. FineUI开源版之TreeGrid实现
  13. (cljs/run-at (JSVM. :browser) &quot;搭建刚好可用的开发环境!&quot;)
  14. nopCommerce 3.9 大波浪系列 之 汉化-中文语言
  15. Unhandled event loop exception No more handles
  16. Python之sqlite3
  17. 【纯&#183;技术干货】更 App 化的小程序开发
  18. U盘被写保护不能重新格式化
  19. php 常用的标签比较
  20. luoguP3366 [模板] 最小生成树

热门文章

  1. python基础25 -----python高级用法
  2. Android:日常学习笔记(8)———探究UI开发(3)
  3. jQuery中的部分方法
  4. $《第一行代码:Android》读书笔记——第6章 数据持久化
  5. JAVA ArrayUtils 数组工具类
  6. Android摄像头测量尺(Advanced Ruler Pro)使用方法
  7. 解决Newtonsoft.Json版本问题
  8. poj 1905 Expanding Rods(木杆的膨胀)【数学计算+二分枚举】
  9. Oracle常用知识小总结
  10. JAVA使用Freemarker生成静态文件中文乱码