![]() |
Home | Libraries | People | FAQ | More |
BidirectionalIterator 雙向迭代器
A bidirectional iterator is an iterator that can read through a sequence
of values. It can move in either direction through the sequence, 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
迭代器的類別
i, j
xcategory must be derived from std::bidirectional_iterator_tag.
category 必須派生自 std::bidirectional_iterator_tag。
| Name 名字 | Expression 表達式 | Type 類型 | Precondition 前置條件 | Semantics 語義 | Postcondition 後置條件 |
|---|---|---|---|---|---|
Predecrement 前綴遞減 |
--i |
Iter & |
|
||
Postdecrement 後綴遞減 |
i-- |
Iter |
Same as for predecrement 與前綴遞減相同 |
Equivalent to
|
|
&i = &(--i)
i == j implies --i == --j
++i; --i; and --i; ++i; must end up with the
value of i unmodified, if i both of the
operations in the pair are valid.
++i; --i; 和 --i; ++i; 必須以原來的 i 值結束,如果 i 在兩個操作中均有效。