vector 的使用
来源:互联网 发布:中国家暴数据统计 编辑:程序博客网 时间:2024/04/28 13:45
size/resize 以及 capacity/reserve 之间的区别
size 取得 vector 中元素的个数,resize 重新分配空间,并且将分配的空间初始化为0,
capacity : return number of elements for while memory has been allocated
reserve:Allocates elements for vector to ensure a minimum size,preserving its contents if the new size is larger than existing size,buf not initializationvalue for zero.
所以我们只可以使用operator[] 或 at() 去修改实在存在于容器中的元素.
1.尽量做到const 正确性
2。尽量使用 != 而不是使用 < 来比较两个迭代器
3。尽量使用前缀的 -- 与 ++,因为后缀的++ 与-- 使用到临时变量
4。避免无谓的求值
5。尽量使用"/n"而不是endl. 使用endl 会迫使输出流刷新其缓冲区
6。尽量使用标准库中的copy 与for_each,而不是自己手写循环
- vector的使用
- Vector 的使用
- Vector类的使用
- vector 的使用
- Vector类的使用
- java vector的使用
- vector的一点使用
- vector iterator 的使用
- vector的使用
- vector的简单使用
- vector的使用
- vector的使用
- 容器Vector的使用
- vector的嵌套使用
- vector的使用
- vector的使用
- vector的使用
- Vector的使用
- 35岁前成功的12条黄金法则
- 简单的用户登陆判断
- ACM UVa 算法题 #108 - Maximum Sum的解法
- C语言之可变参数问题
- 浩方战网平台分析
- vector 的使用
- ASP.net新手经常会碰到的问题
- VC Studio 使用技巧大全
- ASP.NET热点问题解答14个
- 清华 VS MIT 对比才知道我们的教育是多么失败
- Nutch爬虫工作流程
- 转贴:linux下的精确wait
- 替代 SWT GridData 更简单有效的方法
- ORA-01480 trailing null missing from STR bind value 错误解决方法