Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of boost. Click here for the latest Boost documentation.

[Home]Random Access Iterator

Description

A Random Access Iterator is a Bidirectional Iterator that provides constant-time methods for moving forward and backward on a sequence in arbitrary-sized steps.

Refinement of

Bidirectional Iterator

Valid expressions

Random Access Iterator defines two new expressions and refines the ones described in Bidirectional Iterator.

 Expression  Expression type  
typename i::nextA model of Random Access Iterator
typename i::priorA model of Random Access Iterator
typename i::template advance<n>::typeA model of Random Access Iterator
typename i::template distance<j>::typeA model of Integral Constant

Expression semantics

Semantics of an expression is defined only where it is not defined in Bidirectional Iterator.

 Expression  Complexity  Precondition  Semantics  Postcondition  
typename i::template advance<n>::typeAmortized constant timeIncluding i itself, there must be n::value dereferenceable or past-the-end iterators following or preceding i, depending on whether n is positive or negative.If n::value > 0, equivalent to executing i::next n::value times; if n::value < 0, equivalent to executing i::prior n::value times; if n::value == 0, this is a null operation [1].The resulting iterator is dereferenceable or past-the-end.
typename i::template distance<j>::typeAmortized constant timeEither i is reachable from j or j is reachable from i, or both.Returns an integral constant n such that i::template advance<n>::type is identical to j.

Invariants

For any random access iterators i and j the following invariants always hold:

See also

Random Access Sequence, Bidirectional Iterator


Table of Contents
Last edited July 15, 2002 11:35 am