单独删除std::vector <std::vector<string> > 的所有元素
下面为测试代码:
1.创建
std::vector< std::vector<string> > vc2;
2.初始化
std::vector<string> vc;
vc.push_back("v11");
vc.push_back("v12");
vc.push_back("v13"); std::vector<string> v2;
v2.push_back("v21");
v2.push_back("v22");
v2.push_back("v23"); std::vector<string> v3;
v3.push_back("v21");
v3.push_back("v22");
v3.push_back("v23"); vc2.push_back(vc);
vc2.push_back(v2);
vc2.push_back(v3);
3.执行删除操作
for (std::vector<std::vector<string> >::iterator i = vc2.begin(); i != vc2.end();) {
for (std::vector<string>::iterator j = i->begin(); j != i->end(); ) {
j = i->erase(j);
}
i = vc2.erase(i);
}
单独删除std::vector <std::vector<string> > 的所有元素的更多相关文章
- C++ 实现vector<std:string> 版本
#include <iostream> #include <vector> #include <memory> #include <thread> #i ...
- matlab转c++代码实现(主要包含C++ std::vector,std::pair学习,包含数组与常数相乘,数组相加减,将数组拉成一维向量,图片的读入等内容)
MATLAB部分: xmap = repmat( linspace( -regionW/2, regionW/2, regionW), regionH, 1 );%linspace [x1,x2,N] ...
- std::vector<std::vector<> >
上次看到这个有点晕了,其实这个vector保存的是std::vector<> #include <vector> #include <iostream> using ...
- C++ Arrays, std::array, std::vector 总结
原文来自: https://shendrick.net/Coding%20Tips/2015/03/15/cpparrayvsvector.html @Seth Hendrick Original a ...
- 把vector中的string对象导入到字符指针数组中
#include <iostream>#include <string>#include <vector>//#include <cctype>#inc ...
- 编写程序,从vector<char>初始化string
#include<iostream> #include<string> #include<vector> using namespace std; int main ...
- 没有与这些操作数匹配的 "<<" 运算符 操作数类型为: std::ostream << std::string
错误显示:没有与这些操作数匹配的 "<<" 运算符 操作数类型为: std::ostream << std::string 错误改正:要在头文 ...
- LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++>
LeetCode 26 Remove Duplicates from Sorted Array [Array/std::distance/std::unique] <c++> 给出排序好的 ...
- std::binary_serach, std::upper_bound以及std::lower_bound
c++二分查找的用法 主要是 std::binary_serach, std::upper_bound以及std::lower_bound 的用法,示例如下: std::vector<int& ...
随机推荐
- git - 简易指南
http://www.bootcss.com/p/git-guide/ git - 简易指南
- javascript whenReady
var whenReady=(function(){ var funcs=[]; var ready=false; function handler(e){ if (ready) { return; ...
- php mysql_insert_id()
mysql_insert_id mysql_insert_id()返回给定的 link_identifier中上一步 INSERT 查询中产生的 AUTO_INCREMENT 的 ID 号.如果没有指 ...
- php静态
static 是定义一个静态对象或静态变量,关于static 定义的变量或类方法有什么特性我们看完本文章的相关实例后就见分晓了. 1. 创建对象$object = new Class(),然后使用”- ...
- 《Linux内核设计与实现》读书笔记 - 目录 (完结)【转】
转自:http://www.cnblogs.com/wang_yb/p/3514730.html 读完这本书回过头才发现, 第一篇笔记居然是 2012年8月发的, 将近一年半的时间才看完这本书(汗!! ...
- Linux系统时间与RTC时间【转】
http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=3637782 Linux的RTC驱动相对还是比较简单的,可以将它作为一个普通的字符 ...
- ZOJ Problem Set - 3861 Valid Pattern Lock(dfs)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3861 这道题当时没做出来,后来经过队友提醒才做出来. 3*3的九宫格,给你 ...
- Linux天天见
一.Linux基础篇 1. 发行版本 redhat/centos/suse/debian/ 2. 目录结构 /bin /boot -> grub /dev /etc ->init.d sy ...
- jsonp获取服务器数据的方式
jsonp获取服务器的数据,有两种 一,跨域 二,不跨域 如果跨域 js的写法有两种 1, <script type="text/javascript"> $(func ...
- hdu4003Find Metal Mineral(树形DP)
4003 思维啊 dp[i][j]表示当前I节点停留了j个机器人 那么它与父亲的关系就有了 那条边就走了j遍 dp[i][j] = min(dp[i][j],dp[child][g]+dp[i][j- ...