Concept RandomAccessIterator
RandomAccessIterator
一 个 random access iterator 是一个能够读取一个值序列的 iterator 。它可以沿着 sequence 的两个方向运动(一次移动任意距离都可以保证在 constant time 内),而且可以是 mutable (它所指向的数据可以被改变)或者是 not mutable 。
一个 iterator 表示一个 sequence 中的一个 position 。也就是说, iterator 能够指向 sequence 的内部(当 dereferenced 及被 incrementable 时,返回一个 value ),或者 off-the-end (不能 dereferenceable 或 incrementable )。
Refinement of(强化自)
Associated types(相关型别)
-
value_type
std::iterator_traits
::value_type The value type of the iterator
-
category
std::iterator_traits
::iterator_category The category of the iterator
-
difference_type
std::iterator_traits
::difference_type The difference type of the iterator (measure of the number of steps between two iterators)
Notation(符号)
- Iter
- A type playing the role of iterator-type in the RandomAccessIterator concept.
-
i,j - Objects of type Iter
x- Object of type value_type
n- Object of type difference_type
int_off- Object of type int
Valid expressions(有效表达式)
| Name | Expression | Type | Semantics |
|---|---|---|---|
Motion | i += n | Iter & | Equivalent to applying |
Motion (with integer offset) | i += int_off | Iter & | Equivalent to applying |
Subtractive motion | i -= n | Iter & | Equivalent to |
Subtractive motion (with integer offset) | i -= int_off | Iter & | Equivalent to |
Addition | i + n | Iter | Equivalent to |
Addition with integer | i + int_off | Iter | Equivalent to |
Addition (count first) | n + i | Iter | Equivalent to |
Addition with integer (count first) | int_off + i | Iter | Equivalent to |
Subtraction | i - n | Iter | Equivalent to |
Subtraction with integer | i - int_off | Iter | Equivalent to |
Distance | i - j | difference_type | The number of times |
Element access | i[n] | const-if-not-mutable value_type & | Equivalent to |
Element access with integer index | i[int_off] | const-if-not-mutable value_type & | Equivalent to |

没有评论:
发表评论