| Precondition | Semantics | Postcondition | ||
|---|---|---|---|---|
| Predecrement | --i | |||
| Postdecrement | i-- | Equivalent to |
The complexity of operations on bidirectional iterators is guaranteed to be amortized constant time.
| Symmetry of increment and decrement | If |
• T*
• list<T>::iterator
Input Iterator, Output Iterator, Forward Iterator, Random Access Iterator, Iterator overview
Random Access Iterator
Category: iterators
Component type: concept
A Random Access Iterator is an iterator that provides both increment and decrement (just like a Bidirectional Iterator), and that also provides constant-time methods for moving forward and backward in arbitrary-sized steps. Random Access Iterators provide essentially all of the operations of ordinary C pointer arithmetic.
Bidirectional Iterator, LessThan Comparable
The same as for Bidirectional Iterator
X A type that is a model of Random Access Iterator
T The value type of
Distance The distance type of
i, j Object of type
t Object of type
n Object of type
In addition to the expressions defined in Bidirectional Iterator, the following expressions must be valid.
| Name | Expression | Type requirements | Return type |
|---|---|---|---|
| Iterator addition | i += n | X& | |
| Iterator addition | i + n orn + i | X | |
| Iterator subtraction | i –= n | X& | |
| Iterator subtraction | i – n | X | |
| Difference | i – j |
