`
阿尔萨斯
  • 浏览: 4193151 次
社区版块
存档分类
最新评论

STL vector方法总结(二)Iterators(35)

 
阅读更多
这里是vector的所有构造方法,成员方法的一些总结,具体的可以详看后面的链接。
public member function
<vector>

std::vector::begin

      iterator begin();
const_iterator begin() const;

该方法返回一个指向该vector中第一个元素的iterator.

需要注意的是,和front()方法不同,front是返回第一个元素的引用,而begin返回的是一个指向第一个元素的随机访问迭代器。

如果vector是空的,使用begin返回的迭代器不应该被解除引用。

Parameters

参数:无


Return Value

返回值:

指向该顺序容器第一个元素的迭代器。

原文地址:http://blog.csdn.net/qq844352155/article/details/38456669




———————————————————————————————————————————————————

public member function
<vector>

std::vector::end

      iterator end() noexcept;
const_iterator end() const noexcept;
Return iterator to end
返回一个超尾迭代器指向vector容器最后元素的再下一个元素(这个位置是没有元素存在的)。

这个超尾元素是一个假设紧跟容器最后一个元素的下一个位置的元素,但是该超尾迭代器本身是不指向任何元素的,因此不应该被解除引用。

因为标准库里面用于指示范围的函数并没有包含被超尾迭代器所指向的元素,这个函数通常联合begin一起来使用用于指出容器范围内的所有元素。区间范围为[begin,end)

如果容器是空的,那么这个函数的返回值和begin是一样的。

Parameters

none

Return Value

返回值是一个超尾迭代器,指向超出序列范围外的一个位置。

如果vector对象本身具有const属性,那么将返回一个const_iterator,否则,返回一个普通的iterator.

该迭代器的类型属于随机访问迭代器类型。

原文地址:http://blog.csdn.net/qq844352155/article/details/38486629



———————————————————————————————————————————————————

public member function
<vector>

std::vector::rbegin

      reverse_iterator rbegin() noexcept;
const_reverse_iterator rbegin() const noexcept;
返回一个反向的首元素.

返回一个指向最后一个元素的反向迭代器 (相当于从后往前看)

反向迭代器的向后迭代:当增加该反向迭代器的时候其实该迭代器是向容器的开头位置移动

Parameters

none

Return Value

返回值:

返回一个反向迭代器指向顺序容器的反向的开头。

原文地址:http://blog.csdn.net/qq844352155/article/details/38458505




———————————————————————————————————————————————————
public member function
<vector>

std::vector::rend

      reverse_iterator rend() noexcept;
const_reverse_iterator rend() const noexcept;

返回一个反向的迭代器指向假设中存在于vector第一个元素前面一个位置的元素(这个元素被认为是反转后的尾部)

范围rbegin和rend之间就包含了vector(倒序)的所有元素。

Parameters

none

Return Value

一个反向迭代器指向一个序列倒序的超尾。

原文地址:http://blog.csdn.net/qq844352155/article/details/38515303




———————————————————————————————————————————————————
public member function
<array>

std::array::cbegin

const_iterator cbegin() const noexcept;

返回一个指向array容器第一个元素的const_iterator.

Parameters

none

Return Value

返回值为一个指向序列开头的const_iterator。
原文地址:http://blog.csdn.net/qq844352155/article/details/38854437




———————————————————————————————————————————————————
public member function
<vector>

std::vector::cend

const_iterator cend() const noexcept;

返回一个具有const属性的iterator指向超尾元素。

一个const_iterator是一种类似于指向常量的迭代器,他们可以被递增或是递减(除非这个iterator本身是常量才不能这样),这就像和end()返回的iterator一样,只是cend()返回的迭代器不能用于修改该元素而已,甚至vector本身并不是const属性,该方法返回的iterator也是不能用于修改元素的.

Parameters

none

Return Value

返回值为一个const_iterator指向序列的超尾元素。

返回的iterator属于随机访问迭代器。

原文地址:http://blog.csdn.net/qq844352155/article/details/38511677




———————————————————————————————————————————————————

public member function
<array>

std::array::crbegin

const_iterator crbegin() const noexcept;

返回一个const_reverse_iterator指向array容器的最后一个元素。

Parameters

none

Return Value

返回一个反转的指向序列开头的迭代器。

原文地址:http://blog.csdn.net/qq844352155/article/details/38857821



———————————————————————————————————————————————————

public member function
<vector>

std::vector::crend

const_reverse_iterator crend() const noexcept
返回一个const_reverse_iterator(具有const属性的reverse_iterator)指向假设存在于一个倒序容器的最后一个位置后的超尾元素。(超尾元素本身并不是实际存在的)


Parameters

none

Return Value

返回一个const_reverse_iterator指向倒序序列的尾部。

原文地址:http://blog.csdn.net/qq844352155/article/details/38516395

——————————————————————————————————————————————————————————————————

//总结的不好的地方请多多指导,可以在下面留言或者点击左上方邮件地址给我发邮件,指出我的错误以及不足,以便我修改,更好的分享给大家,谢谢。

转载请注明出处:http://blog.csdn.net/qq844352155
author:天下无双

Email:coderguang@gmail.com

2014-8-27

于GDUT

——————————————————————————————————————————————————————————————————







分享到:
评论

相关推荐

    Effictive STL CHM中文版

    》灰《《常好的STL教程Effective STL 目录 容器 条款1: 仔细选择你要的容器 条款2: 小心对“容器无关代码”的幻想 条款3: 使容器里对象的拷贝操作轻量而正确 条款4: 用empty来代替检查size是否为0 条款5: ...

    标准模板库STL

    STL容器部分主要由头文件&lt;vector&gt;、、、、、和组成。 (2)算法(Algorithms)。包括各种基本算法,如比较、交换、查找、排序、遍历操作、复制、修改、移除、反转、合并等等。 STL算法部分主要由头文件和组成。...

    STL源码剖析.pdg

    sgi stl 内部文件(sgi stl真正实现于此) 018 1.8.3 sgi stl 的组态设定(configuration) 019 1.9可能令你困惑的c++ 语法 026 1.9.1 stl_config.h 中的各种组态 027 组态3:static template member 027 组态5...

    STL源码剖析简体中文完整版(清晰扫描带目录).pdf

    第1 章 STL 概论与著作版本简介 第2 章 空间配置器(allocator) 第3 章 迭代器(iterators)概念与 traits 编程技法 第4 章 序列式容器(sequ ence containers) 第5 章 开关式容器(associated containers) 第6 ...

    STL 源码剖析(侯捷先生译著)

    内容简介回到顶部↑这本书不适合C++ 初学者,不适合 Genericity(泛型技术)初学者,或 STL 初学者。这本书也不适合带领你学习面向对象(Object Oriented)技术 — 是的,STL 与面向对象没有太多关连。本书前言清楚...

    STL入门快速入门教程-----学习C++

    STL重要部分,包含了许多数据结构,有vector(动态增加的数组),queue(队列),stack(堆栈)……甚至也包括string,它也可以看做为一种容器,并且适用所有的容器可用的方法。 7:算法(algorithms)部分。STL重要...

    effective stl 中文 pdf

    条款27: 使用distance和advance把const_iterators转化成iterators 条款28: 了解如何通过reverse_iterator的base得到iterator 条款29: 需要一字符一字符输入时请用istreambuf_iterator 算法 条款30: 确保目的范围...

    《STL源码剖析》(候捷 著)

    这本书所呈现的源码,使读者看到vector的实现、list的实现、heap的实现、deque的实现、Red Black tree的实现、hash table的实现、set/map的实现;看到各种算法(排序、查找、排列组合、数据移动与复制技术)的实现;...

    STL Overview Sessions

    STL Overview Sessions 3~4. 1 STL Containers 1.1 Review 1.2 Common Operations of Container Classes 1.3 A Sample of using vector 2 Auto_ptr & Smart point 2.1 How to use STL auto_ptr ...3 STL Iterators

    C++STL程序员开发指南【可搜索+可编辑】

    第二篇C++ STL 技术原理和组成 第3 章STL 技术原理· · · · · · · · · · · · · · · · · ·................................. 103 3-1 模板概述· · · · · · • · · · · · · · · · ·...

    c++ STL容器总结之:vertor与list的应用

    3、迭代器(iterators):扮演容器与算法之间的胶合剂,是所谓的“泛型指针”。所有STL容器都有自己的专属的迭代器。 4、仿函数(functors):行为类似函数,可以作为算法的某些策略。从实现的角度来看,仿函数是一...

    at42ft_containers:重新实现STL中的某些容器(矢量,列表,地图,堆栈,队列和&及其迭代器,const_iterators,reverse_iterators)[C ++]

    at42ft_containers:重新实现STL中的某些容器(矢量,列表,地图,堆栈,队列和&及其迭代器,const_iterators,reverse_iterators)[C ++]

    C++标准库(第二版)英文版.pdf

    C++标准库(第二版)英文版.pdf 非扫描版+源代码 Prefaceto the SecondEdition xxiii Acknowledgments for the SecondEdition xxiv Prefaceto the FirstEdition xxv Acknowledgments for the FirstEdition xxvi 1 ...

    Addison.Wesley.C++.by.Dissection.2002.pdf

    6.6.2 vector&lt;&gt; in STL....... 267 6.6.3 Using complex&lt;&gt;...... . . . 267 6.6.4 limits and Other Useful Templates.... . . 268 6.7 Software Engineering: Reuse and Generics.... . 269 6.7.1 Debugging ...

    visual assist v 10.4.1632 with crack

    (case=9436) STL list&lt;&gt; and vector&lt;&gt; member lists appear correctly following a "using namespace std::list" or "using namespace std::vector" directive. (case=12345) 7226 Empty C++ preprocessor ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    Table of Contents Header Files The #define Guard Header File Dependencies Inline Functions The -inl.h Files Function Parameter Ordering Names and Order of Includes Scoping Namespaces Nested Classes ...

Global site tag (gtag.js) - Google Analytics