Effective STL 条款9
来源:互联网 发布:35岁考本科 知乎 编辑:程序博客网 时间:2024/05/16 19:00
在删除选项中仔细选择
本节核心内容:
如何高效的删除容器中的指定数据
结论如下:
1.去除一个容器中有特定值的所有对象
如果容器是vector
,string
或者deque
,使用erase-remove
惯用法。
如果容器是list
,使用list::remove
如果容器是标准关联容器,使用它的erase
成员函数
2:去除一个容器中满足一个特定判定式的所有对象:
如果容器是vector
,string
或者deque
,使用erase-remove_if
惯用法。
如果容器是list
,使用list::remove_if
如果容器是标准关联容器,使用它的remove_copy_if
和swap成员函数
3:在循环做一些事情的时候记得保证迭代器的有效性。
以上做法主要是为了提高容器使用的高效性。
1 0
- Effective STL 条款9
- Effective STL学习笔记-条款8-9
- Effective STL 条款17
- Effective STL 条款18
- Effective STL 条款16
- Effective STL 条款7
- Effective STL条款50
- Effective STL 条款35
- Effective STL 条款37
- Effective STL 条款1
- Effective STL条款21
- Effective STL条款44
- Effective STL条款16
- Effective STL条款29
- Effective STL 条款18
- Effective STL 条款1
- Effective STL 条款30
- Effective STL 条款2
- JQuery选择器整理
- 灰度图像--图像增强 双边滤波 Bilateral Filtering
- leetCode 230.Kth Smallest Element in a BST
- 如何用ddms看占用内存的方法.
- php调用webservice的几种方法
- Effective STL 条款9
- openstack keystone v2 to v3
- 格式化金额,每隔三位加逗号
- 浅谈PHP进程管理
- 《iOS Human Interface Guidelines》——App Icon
- Android中ExpandableListView中嵌套ListView
- LeetCode #5 Longest Palindromic Substring C# Solution
- linux 命令 查看定时任务crontab
- pjsip(2.4.5)增加视频功能