vector::begin
来源:互联网 发布:蓝牙耳机配对软件 编辑:程序博客网 时间:2024/04/29 21:22
Return iterator to beginning
Returns an iterator pointing to the first element in the vector.Notice that, unlike member vector::front, which returns a reference to the first element, this function returns arandom access iterator pointing to it.
If the container is empty, the returned iterator value shall not be dereferenced.
Parameters(参数)
noneReturn Value
An iterator to the beginning of the sequence container.If the vector object is const-qualified, the function returns a const_iterator. Otherwise, it returns an iterator.
Member types iterator and const_iterator are random access iterator types (pointing to an element and to a const element, respectively).
// vector::begin/end#include <iostream>#include <vector>using namespace std;int main (){ vector<int> myvector; for (int i=1; i<=5; i++) myvector.push_back(i); cout << "myvector contains:"; for (vector<int>::iterator it = myvector.begin() ; it != myvector.end(); ++it) cout << ' ' << *it; cout << endl; return 0;}
---------------------------------------------------
// vector::begin/end#include <iostream>#include <vector>using namespace std;int main (){ vector<int> myvector; for (int i=1; i<=5; i++) myvector.push_back(i); cout << "myvector contains:"; vector<int>::iterator it; for (it = myvector.begin() ; it != myvector.end(); ++it) cout << ' ' << *it; cout << endl; return 0;}
Output:
myvector contains: 1 2 3 4 5
----------------------------------
1 0
- vector::begin
- vector 中[begin, end)
- Be careful to use iterator - vector.begin()
- Sample of STL(Vector):begin and rbegin
- vector迭代器的begin()和end()
- c++ vector begin(),end(),rbegin(),rend()问题
- STL vector中的begin方法(3)
- c++ vector begin(),end(),rbegin(),rend()问题
- vector之begin(),end(),front(),back()
- c++ vector begin(),end(),rbegin(),rend()问题
- BEGIN...
- Begin!
- begin
- Begin
- Begin!
- begin
- BEGIN
- Begin
- Objective c中的锁 NSLock,NSConditionLock,NSRecursiveLock
- 整数在内存中的表达
- 复杂度nlog(n)之归并排序
- 文件系统缓存dirty_ratio与dirty_background_ratio两个参数区别
- Git 一篇搞定基本操作
- vector::begin
- 【Mariadb】centos7搭建mariadb Galera集群
- 【Linux】进程的创建fork()和vfork()
- 解决磁盘io紧张的一种临时方法
- Android提高启动速度的实现方法 7.23
- 173. Binary Search Tree Iterator
- H5学习之4 拖拽元素 放置元素2
- soft raid5阅读笔记之七--MD中的bitmap
- 解决IllegalStateException: Can not perform this action after onSaveInstanceState