Iterator Concepts
An Iterator is a restricted pointer-like object pointing into a vector or matrix container.
Indexed Bidirectional Iterator
Description
An Indexed Bidirectional Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.
Refinement of
Assignable, Equality Comparable, Default Constructible.
Associated types
Value type |
The type of the value obtained by dereferencing a Indexed Bidirectional Iterator |
Container type |
The type of the container a Indexed Bidirectional Iterator points into. |
Notation
|
A type that is a model of Indexed Bidirectional Iterator |
|
The value type of |
|
The container type of |
|
Objects of type |
|
Object of type |
|
Object of type |
Definitions
A Indexed Bidirectional Iterator may be mutable, meaning that the values referred to by objects of that type may be modified, or constant , meaning that they may not. If an iterator type is mutable, this implies that its value type is a model of Assignable; the converse, though, is not necessarily true.
A Indexed Bidirectional Iterator may have a singular value, meaning that the results of most operations, including comparison for equality, are undefined. The only operation that is guaranteed to be supported is assigning a nonsingular iterator to a singular iterator.
A Indexed Bidirectional Iterator may have a dereferenceable value, meaning that dereferencing it yields a well-defined value. Dereferenceable iterators are always nonsingular, but the converse is not true.
An Indexed Bidirectional Iterator is past-the-end if it points beyond the last element of a container. Past-the-end values are nonsingular and nondereferenceable.
Valid expressions
In addition to the expressions defined for Assignable, Equality Comparable and Default Constructible, the following expressions must be valid.
Name |
Expression |
Type requirements |
Return type |
Default constructor |
|
|
|
Dereference |
|
|
Convertible to |
Dereference assignment |
|
|
|
Member access |
|
|
|
Preincrement |
|
|
|
Postincrement |
|
|
|
Predecrement |
|
|
|
Postdecrement |
|
|
|
Index |
|
|
|
Expression Semantics
Semantics of an expression is defined only where it differs from, or is not defined in, Assignable, Equality Comparable and Default Constructible.
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Default constructor |
|
|
|
|
Dereference |
|
|
|
|
Dereference assignment |
|
Same as for |
|
|
Member access |
|
|
Equivalent to
|
|
Preincrement |
|
|
|
|
Postincrement |
|
Same as for |
Equivalent to |
|
Predecrement |
|
|
|
|
Postdecrement |
|
Same as for — |
Equivalent to |
|
Index |
|
|
|
If |
Complexity guarantees
The complexity of operations on indexed bidirectional iterators is guaranteed to be amortized constant time.
Invariants
Identity | it1 == it2 if and only if &*it1 == &*it2 . |
---|---|
Symmetry of increment and decrement |
If |
Relation between iterator index and container element operator |
If |
Models
-
sparse_vector::iterator
Indexed Random Access Iterator
Description
An Indexed Random Access Iterator is an iterator of a container that can be dereferenced, moved forward, moved backward and carries index information.
Refinement of
LessThanComparable, Indexed Bidirectional Iterator .
Associated types
Value type |
The type of the value obtained by dereferencing a Indexed Random Access Iterator |
Container type |
The type of the container a Indexed Random Access Iterator points into. |
Notation
|
A type that is a model of Indexed Random Access Iterator |
|
The value type of |
|
The container type of |
|
Objects of type |
|
Object of type |
|
Object of type |
Definitions
An Indexed Random Access Iterator it1
is reachable from an Indexed
Random Access Iterator it2
if, after applying operator ++
to it2
a
finite number of times, it1 == it2
.
Valid expressions
In addition to the expressions defined for Indexed Bidirectional Iterator , the following expressions must be valid.
Name |
Expression |
Type requirements |
Return type |
Forward motion |
|
|
|
Iterator addition |
|
|
|
Backward motion |
|
|
|
Iterator subtraction |
|
|
|
Difference |
|
|
|
Element operator |
|
|
Convertible to |
Element assignment |
|
|
Convertible to |
Expression Semantics
Semantics of an expression is defined only where it differs from, or is not defined in, Indexed Bidirectional Iterator .
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Forward motion |
|
Including |
If |
|
Iterator addition |
|
Same as for |
Equivalent to |
Result is dereferenceable or past-the-end. |
Backward motion |
|
Including |
Equivalent to
|
|
Iterator subtraction |
|
Same as for |
Equivalent to |
Result is dereferenceable or past-the-end. |
Difference |
|
Either |
Returns a number |
|
Element operator |
|
|
Equivalent to |
|
Element assignment |
|
Same as for |
Equivalent to
|
|
Complexity guarantees
The complexity of operations on indexed random access iterators is guaranteed to be amortized constant time.
Invariants
Symmetry of addition and subtraction |
If |
Relation between distance and addition |
If |
Reachability and distance |
If |
Models
-
vector::iterator
Indexed Bidirectional Column/Row Iterator
Description
An Indexed Bidirectional Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.
Refinement of
Assignable, Equality Comparable, Default Constructible.
Associated types
Value type |
The type of the value obtained by dereferencing a Indexed Bidirectional Column/Row Iterator |
Container type |
The type of the container a Indexed Bidirectional Column/Row Iterator points into. |
Notation
|
A type that is a model of Indexed Bidirectional Column/Row Iterator |
|
A type that is a model of Indexed Bidirectional Row/Column Iterator |
|
The value type of |
|
The container type of |
|
Objects of type |
|
Objects of type |
|
Object of type |
|
Object of type |
Definitions
Valid expressions
In addition to the expressions defined for Assignable, Equality Comparable and Default Constructible, the following expressions must be valid.
Name |
Expression |
Type requirements |
Return type |
Default constructor |
|
|
|
Dereference |
|
|
Convertible to |
Dereference assignment |
|
|
|
Member access |
|
|
|
Preincrement |
|
|
|
Postincrement |
|
|
|
Predecrement |
|
|
|
Postdecrement |
|
|
|
Row Index |
|
|
|
Column Index |
|
|
|
Row/Column Begin |
|
|
|
Row/Column End |
|
|
|
Reverse Row/Column Begin |
|
|
|
Reverse Row/Column End |
|
|
|
Expression Semantics
Semantics of an expression is defined only where it differs from, or is not defined in, Assignable, Equality Comparable and Default Constructible.
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Default constructor |
|
|
|
|
Dereference |
|
|
|
|
Dereference assignment |
|
Same as for |
|
|
Member access |
|
|
Equivalent to
|
|
Preincrement |
|
|
|
|
Postincrement |
|
Same as for |
Equivalent to |
|
Predecrement |
|
|
|
|
Postdecrement |
|
Same as for — |
Equivalent to |
|
Row Index |
|
If |
|
If |
Column Index |
|
If |
|
If |
Row/Column Begin |
|
|
If If |
|
Row/Column End |
|
|
If If |
|
Reverse Row/Column Begin |
|
|
Equivalent to |
|
Reverse Row/Column End |
|
|
Equivalent to |
|
Complexity guarantees
The complexity of operations on indexed bidirectional column/row iterators is guaranteed to be logarithmic depending on the size of the container. The complexity of one iterator (depending on the storage layout) can be lifted to be amortized constant time. The complexity of the other iterator (depending on the storage layout and the container) can be lifted to be amortized constant time for the first row/first column respectively.
Invariants
Identity | it1 == it2 if and only if &*it1 == &*it2 . |
---|---|
Symmetry of increment and decrement |
If |
Relation between iterator index and container element operator |
If |
Relation between iterator column/row begin and iterator index |
If If |
Relation between iterator column/row end and iterator index |
If If |
Models
-
sparse_matrix::iterator1
-
sparse_matrix::iterator2
Indexed Random Access Column/Row Iterator
Description
An Indexed Random Access Column/Row Iterator is an iterator of a container that can be dereferenced, incremented, decremented and carries index information.
Refinement of
Associated types
Value type |
The type of the value obtained by dereferencing a Indexed Random Access Column/Row Iterator |
Container type |
The type of the container a Indexed Random Access Column/Row Iterator points into. |
Notation
|
A type that is a model of Indexed Random Access Column/Row Iterator |
|
The value type of |
|
The container type of |
|
Objects of type |
|
Object of type |
|
Object of type |
Definitions
Valid expressions
In addition to the expressions defined for Indexed Bidirectional Column/Row Iterator , the following expressions must be valid.
Name |
Expression |
Type requirements |
Return type |
Forward motion |
|
|
|
Iterator addition |
|
|
|
Backward motion |
|
|
|
Iterator subtraction |
|
|
|
Difference |
|
|
|
Element operator |
|
|
Convertible to |
Element assignment |
|
|
Convertible to |
Expression Semantics
Semantics of an expression is defined only where it differs from, or is not defined in, Indexed Bidirectional Column/Row Iterator .
Name | Expression | Precondition | Semantics | Postcondition |
---|---|---|---|---|
Forward motion |
|
Including |
If |
|
Iterator addition |
|
Same as for |
Equivalent to |
Result is dereferenceable or past-the-end. |
Backward motion |
|
Including |
Equivalent to
|
|
Iterator subtraction |
|
Same as for |
Equivalent to |
Result is dereferenceable or past-the-end. |
Difference |
|
Either |
Returns a number |
|
Element operator |
|
|
Equivalent to |
|
Element assignment |
|
Same as for |
Equivalent to
|
|
Complexity guarantees
The complexity of operations on indexed random access Column/Row iterators is guaranteed to be amortized constant time.
Invariants
Symmetry of addition and subtraction |
If |
Relation between distance and addition |
If |
Reachability and distance |
If |
Models
-
matrix::iterator1
-
matrix::iterator2
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Copyright (©) 2021 Shikhar Vashistha
Use, modification and distribution are subject to the Boost Software
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt ).