STL vector中的crbegin方法(7)
来源:互联网 发布:淘宝 同一时间下单人数 编辑:程序博客网 时间:2024/06/05 06:30
其实crbegin就相当于cbegin+rbegin.
关于这两个函数可以看我的上两篇博文。
public member function
<vector>
std::vector::crbegin
const_reverse_iterator crbegin() const noexcept;
Return const_reverse_iterator to reverse beginning
Returns a const_reverse_iterator pointing to the last element in the container (i.e., its reverse beginning).该函数返回一个具有const属性的reverse_iterator,指向该容器的最后一个元素。
Parameters
noneReturn Value
A const_reverse_iterator to the reverse beginning of the sequence.返回值是一个具有const属性的指向序列反向开头的反向迭代器。
返回值的类型属于反向的随机访问迭代器类型。
Example
123456789101112131415
// vector::crbegin/crend#include <iostream>#include <vector>int main (){ std::vector<int> myvector = {1,2,3,4,5}; std::cout << "myvector backwards:"; for (auto rit = myvector.crbegin(); rit != myvector.crend(); ++rit) std::cout << ' ' << *rit; std::cout << '\n'; return 0;}
Edit & Run
Output:
myvector backwards: 5 4 3 2 1
Complexity
Constant.Iterator validity
No changes.Data races
The container is accessed.No contained elements are accessed by the call, but the iterator returned can be used to access them. Concurrently accessing or modifying different elements is safe.
该方法不会实际访问容器里的元素,但是返回的这个iterator可以用来访问元素,并且用他们来访问或者是修改不同的元素都是安全的。(这里似乎有点问题?运用const_cast转换?这里似乎转化不了,什么情况?)Exception safety
No-throw guarantee: this member function never throws exceptions.The copy construction or assignment of the returned iterator is also guaranteed to never throw.
该方法不会抛出异常。
利用复制构造函数或者赋值运算得到该iterator的拷贝也不会抛出异常。
//翻译的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。
转载请注明出处:http://blog.csdn.net/qq844352155
2014-8-11
于GDUT
0 1
- STL vector中的crbegin方法(7)
- STL array的crbegin方法(7)
- STL deque的crbegin方法(10)
- STL vector中的rbegin方法(5)
- STL vector中的cbegin()方法(6)
- STL vector中的rend方法(10)
- STL vector中的crend()方法(11)
- STL vector中的reserve()方法(15)
- STL vector中的push_back方法(17)
- STL vector中的clear方法(18)
- STL vector中的at方法(20)
- STL vector中的pop_back方法(22)
- STL vector中的emplace_back方法(24)
- STL vector中的erase方法(26)
- STL vector中的swap方法(33)
- STL vector中的insert方法
- STL vector中的capacity()方法(14)
- STL vector中的operator=方法(30)
- GDB详解
- 互联网项目备忘(1)
- Struts2官方文档之Result Types (文章摘自Struts2 官方文档,以备以后查看)
- 华为Online judge上机题总结1
- java中类和对象如何协同工作, 这样工作有什么好处?
- STL vector中的crbegin方法(7)
- hdu 2795 Billboard(线段树版)
- 字符串分割
- hdoj.1735 字数统计 20140811
- 开源 免费 java CMS - FreeCMS2.0 会员登录
- 如何在BIOS中设置RAID?
- DFT补零的影响
- Qt Mode/View 学习笔记 —— 概述和Model
- 一点心得