c ++ iterator

来源:互联网 发布:达内培训 大数据 编辑:程序博客网 时间:2024/05/21 10:23
ExpressionReturn TypePrecondition*rreferencer is dereferenceable (see below)++rIt&r is incrementable (see below)




迭代器(Iterator)是用来遍历容器中的每一个元素。迭代器可以被认为一个抽象的指针。



Dereferenceable iterators 解引用迭代


Iterators for which the behavior of the expression *i is defined are called dereferenceable.

Iterators are not dereferenceable if:

1、they are past-the-end iterators or before-begin iterators.
2、they were invalidated by one of the iterator-invalidating operations on the sequence to which they refer.


iterators for which the behavior of the expression ++i is defined are called incrementable.


在迭代器中使用 ++i,返回新的迭代器。

0 0
原创粉丝点击