The features of Vector in C++
来源:互联网 发布:光纤是如何传输数据的 编辑:程序博客网 时间:2024/04/28 16:29
There are so many containers in C++, like vector, list, map and so on. To be honest, I am always confused with these containers since in my point of view, they are somehow similar. But with no doubt, there still exist differences among them. I try to expose these differences by using my experiences. I will start withvector.
1. In order to use vector, we need to add
#include <vector>
using namespace std;
in front.
2. How to define a vector
vector<type> v; ////type could be int, double.....
3. How to insert an element
v.push_back(3);
4. Accessing the elements.
Since vector could be regarded as a dynamic array, so we could use index of vector to access the elements. For instance,v[1], v[2].
Alternatively, we could use iterator.
5. Advantanges and Disadvantanges of vector.
Ad: (1) It's easy to access the elements in vector since we could use index.
(2) It's easy to insert element at the end.
Disad: time-consuming to insert or remove element at positions other than the end.
- The features of Vector in C++
- Features of List in C++
- GIT BASH IN INTELLIJ IDEA 13 ON WINDOWS One of the top features of the recent release of IntelliJ ID
- The features of the film faced plywood
- The features of the film faced plywood
- cheap chanel handbags A handbag is one of the key features in a womans form statement
- The Question about Norm of Vector in MIMO
- Linear regression of multiple features in Tensorflow
- The understanding of string in C.
- The use of sizeof in C
- the features of R.U.B.E
- Main features of the X86-64
- Explain the security features in Oracle.
- review the advance features in Python
- one of the key features of distributed application-managemeability
- one of the key features of distributed application-cost
- The typical features of the film faced plywood
- The typical features of the film faced plywood
- Jamendo开源在线音乐播放器源码分析(四)
- Wdatepicker日期控件的使用指南
- u-boot for tiny210 ver2.1(by liukun321咕唧咕唧)
- 我对计算机科学与技术的期望与目标
- Extjs4---学习笔记,同步更新中。。。
- The features of Vector in C++
- Mysql创建外键约束时,报errno: 150
- Ubuntu_解决Ubuntu无法登录(输入正确用户名和密码仍跳回登录界面)
- 有没有一句深刻的话改变了你,并让你一直付诸实践至今?
- IOS atomic与nonatomic,assign,copy与retain的定义和区别
- 供配电考试经验谈-收藏
- 在一张表中,查询出一个字段相同,一个字段不同的记录
- .NET操作Word的实现:using Word
- Hibernate 连接池的三种配置方式:dbcp , c3p0