C++ unique
来源:互联网 发布:诺亚 大禹 知乎 编辑:程序博客网 时间:2024/06/01 17:06
algorithm中的unique 用于去除指定容器中重复的元素,返回一个没有重复元素的序列的最后一个元素,要打印这样的数据信息则从容器的begin()开始到这个返回的地方就可以了。
vector<string> strvec;
cout << "use unique" << endl;
vector<string>::iterator it = strvec.begin();
vector<string>::iterator ituniq = unique(it,strvec.end());
//ituniq 指向的是去除重复元素之后的最后一个元素位置
cout << "use unique after" << endl;
i = 1;
while(it != ituniq){
cout << i << ":" << *it << endl;
++it;
++i;
}
cout << endl;
按照以上的操作就可以完成对去除重复部分的容器数据打印。
切记:对应的重复数据并没有删除,只是放到了容器unique返回的那个位置之后了
- [leetcode]Unique Paths(C)
- c++unique用法
- c 语言unique 实现
- c++unique 用法
- [C++]LeetCode: 56 Unique Paths
- leetcode 62 C++. Unique Paths
- 【C++】【LeetCode】62. Unique Paths
- [LeetCode] [C++] 62. Unique Paths
- unique
- unique
- unique()
- unique
- unique()
- C++---------lower_bound upper_bound和unique函数
- [C++]LeetCode: 53 Unique Binary Search Trees
- [C++]LeetCode: 78 Unique Paths II
- [leetcode-63]Unique Paths II(c)
- 错误代码: 1066 Not unique table/alias: 'c'
- 在ie浏览器中设置文档模式
- eclipse中工程打jar包工具及其用法
- PHP盲注常用语句
- 设备未托管
- 用Intrepid发送信息
- C++ unique
- Favorite iPad Games
- 修改数据
- 将普通用户添加到sudo组
- Windows完成端口与Linux epoll技术简介
- DatagridView对齐方式的设置
- Maintaining the System
- malloc和Free 工作原理
- ubuntu 下的必备工具 ubuntu - tweak