Forward Iterator

Category: iterators
Component type: concept

Description

A Forward Iterator is an iterator that corresponds to the usual intuitive notion of a linear sequence of values. It is possible to use Forward Iterators (unlike Input Iterator and Output Iterator) in multipass algorithms. Forward Iterators do not, however, allow stepping backwards through a sequence, but only, as the name suggests, forward.

A type that is a model of Forward Iterator may be either mutable or immutable, as defined in the Trivial Iterator requirements.

Refinement of

Input Iterator, Output Iterator

Associated types

The same as for Input Iterator

Notation

X A type that is a model of Forward Iterator
T The value type of X
i, j Object of type X
t Object of type T

Definitions

Valid expressions

Forward Iterator does not define any new expressions beyond those defined in Input Iterator. However, some of the restrictions described in Input Iterator are relaxed.

Name Expression Type requirements Return type
Preincrement ++i   X&
Postincrement i++   X

Expression semantics

Forward Iterator does not define any new expressions beyond those defined in Input Iterator. However, some of the restrictions described in Input Iterator are relaxed.

Name Expression Precondition Semantics Postcondition
Preincrement ++i i is dereferenceable i points to the next value i is dereferenceable or past-the-end. &i == &++i. If i == j, then ++i == ++j. [1]
Postincrement i++ i is dereferenceable Equivalent to {X tmp = i; ++i; return tmp;} i is dereferenceable or past-the-end. [1]

Complexity guarantees

The complexity of operations on Forward Iterators is guaranteed to be amortized constant time.

Invariants

Models

Notes

[1] The restrictions described in Input Iterator have been removed. Incrementing a forward iterator does not invalidate copies of the old value and it is guaranteed that, if i and j are dereferenceable and i == j, then ++i == ++j. As a consequence of these two facts, it is possible to pass through the same Forward Iterator twice.

See also

SkipList, SSkipList, KeyedSkipList, KeyedSSkipList, AutoSkipList, AutoSSkipList, AutoKeyedSkipList, AutoKeyedSSkipList, MultiSkipList, MultiSSkipList, MultiKeyedSkipList, MultiKeyedSSkipList, MultiAutoSkipList, MultiAutoSSkipList, MultiAutoKeyedSkipList, MultiAutoKeyedSSkipList, IndexedSkipList, IndexedSSkipList, IndexedTinySkipList, XIndexedSkipList, XMultiSkipList, XMultiAutoSkipList, AccessSkipList, AccessSSkipList, AutoAccessSkipList, AutoAccessSSkipList, MultiAccessSkipList, MultiAccessSSkipList, MultiAutoAccessSkipList, MultiAutoAccessSSkipList, XMultiAccessSkipList, XMultiAutoAccessSkipList,

Input Iterator, Output Iterator, Bidirectional Iterator, Bidirectional Iterator LOGN, Random Access Iterator, Random Access Iterator LOGN, Arbitrary Access Iterator LOGN, Forward Arbitrary Access Iterator, Forward Arbitrary Access Iterator LOGN, Reverse Arbitrary Access Iterator, Reverse Arbitrary Access Iterator LOGN, Iterator Overview

 All Classes Files Functions Variables Typedefs