Bidirectional IteratorA Bidirectional Iterator is a Forward Iterator that provides a way to obtain the previous element in a sequence.
i is decrementable if there is a "previous" iterator, that is, if i::prior expression is well-defined; iterators pointing to the first element of the sequence are not decrementable.
Bidirectional Iterator both defines a new expression and refines the one described in Forward Iterator.
| Expression | Expression type |
|---|---|
typename i::next | A model of Bidirectional Iterator |
typename i::prior | A model of Bidirectional Iterator |
Semantics of an expression is defined only where it is not defined in Forward Iterator.
| Expression | Complexity | Precondition | Semantics | Postcondition |
|---|---|---|---|---|
typename i::prior | Amortized constant time | i is decrementable | i::prior is an iterator pointing to the previous element of the sequence | i::prior is dereferencable and incrementable |
For any bidirectional iterators i and j the following invariants always hold:
i is incrementable, then i::next::prior is a null operation; similarly, if i is decrementable, i::prior::next is a null operation.
Bidirectional Sequence, Forward Iterator, Random Access Iterator