Precondition Semantics Postcondition
Predecrement --i i is dereferenceable or past-the-end. There exists a dereferenceable iterator j such that i == ++j. i is modified to point to the previous element. i is dereferenceable. &i = &-- i . If i == j , then --i == --j . If j is dereferenceable and i == ++j , then --i == j.
Postdecrement i-- i is dereferenceable or past-the-end. There exists a dereferenceable iterator j such that i == ++j. Equivalent to { X tmp = i; --i; return tmp; }
Complexity guarantees

The complexity of operations on bidirectional iterators is guaranteed to be amortized constant time.

Invariants
Symmetry of increment and decrement If i is dereferenceable, then ++i; -- i; is a null operation. Similarly, --i; ++i; is a null operation.
Models

• T*

• list<T>::iterator

See also

Input Iterator, Output Iterator, Forward Iterator, Random Access Iterator, Iterator overview

Random Access Iterator

Category: iterators

Component type: concept

Description

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.

Refinement of

Bidirectional Iterator, LessThan Comparable

Associated types

The same as for Bidirectional Iterator

Notation

X A type that is a model of Random Access Iterator

T The value type of X

Distance The distance type of X

i, j Object of type X

t Object of type T

n Object of type Distance

Valid expressions

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
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату