![]() |
Home | Libraries | People | FAQ | More |
RandomAccessIterator 隨機訪問迭代器
A random access iterator is an iterator that can read through
a sequence of values. It can move in either direction through the
sequence (by any amount in constant time), and can be either mutable
(data pointed to by it can be changed) or not mutable.
隨機訪問迭代器是一種可以讀入一組值的序列的迭代器。它可以從兩個方向遍歷序列(在常量時間內跳過任意數量),可以是可寫的(所指數據可以改變)或不可寫的。
An iterator represents a position in a sequence. Therefore,
the iterator can point into the sequence (returning a value when
dereferenced and being incrementable), or be off-the-end (and not
dereferenceable or incrementable).
迭代器表示了在一個序列中的某個位置。因此,迭代器可以指向序列內部(在提領時返回一個值且可以遞增),或者指向序列末端之後(不可提領且不可遞
增)
value_type
std::iterator_traits<Iter>::value_type
The value type of the iterator
迭代器的值類型
category
std::iterator_traits<Iter>::iterator_category
The category of the iterator
迭代器的類別
difference_type
std::iterator_traits<Iter>::difference_type
The difference type of the iterator (measure of the number
of steps between two iterators)
迭代器的距離類型(以兩個迭代器間的步數來測量)
i, j
xnint_offcategory must be
derived from std::random_access_iterator_tag.
category 必須派生自 stdrandom_access_iterator_tag。
| 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 |