This class satisfies all requirements of random access iterators defined in the C++ standard. Operations on these iterators are constant in the number of elements in the block vector. However, they are sometimes linear in the number of blocks in the vector, but since that does rarely change dynamically within an application, this is a constant and we again have that the iterator satisfies the requirements of a random access iterator.
The implementation of this class has to work around some problems in compilers and standard libraries. One of these requires us to write all comparison operators twice, once comparison with iterators of the same type and once with iterators pointing to numbers of opposite constness specification. The reason is that if we would have written the comparison operators as a template on the constness of the right hand side, then gcc2.95 signals an error that these operators ambiguate operators declared somewhere within the standard library. Likewise, we have to work around some problems with granting other iterators friendship. This makes the implementation somewhat non-optimal at places, but at least everything works.
typedef Iterator<BlockVectorType,!constness> internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::InverseConstnessIterator [private] |
Typedef an iterator with opposite constness requirements on the elements it points to.
typedef Types<BlockVectorType,constness>::value_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::value_type |
Type of the number this iterator points to. Depending on the value of the second template parameter, this is either a constant or non-const number.
typedef std::random_access_iterator_tag internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::iterator_type |
Declare some typedefs which are standard for iterators and are used by algorithms to enquire about the specifics of the iterators they work on.
typedef ptrdiff_t internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::difference_type |
typedef BlockVectorType::reference internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::reference |
typedef value_type* internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::pointer |
typedef Types<BlockVectorType,constness>::dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::dereference_type |
typedef Types<BlockVectorType,constness>::BlockVector internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::BlockVector |
Typedef the type of the block vector (which differs in constness, depending on the second template parameter).
internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::Iterator | ( | BlockVector & | parent, | |
const unsigned int | global_index | |||
) |
Construct an iterator from a vector to which we point and the global index of the element pointed to.
Depending on the value of the constness
template argument of this class, the first argument of this constructor is either is a const or non-const reference.
internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::Iterator | ( | const Iterator< BlockVectorType, constness > & | c | ) |
Copy constructor.
internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::Iterator | ( | const InverseConstnessIterator< BlockVectorType, constness > & | c | ) |
Copy constructor for conversion between iterators with different constness requirements. This constructor throws an error if an attempt is made at converting a constant to a non-constant iterator.
internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::Iterator | ( | BlockVector & | parent, | |
const unsigned int | global_index, | |||
const unsigned int | current_block, | |||
const unsigned int | index_within_block, | |||
const unsigned int | next_break_forward, | |||
const unsigned int | next_break_backward | |||
) | [private] |
Constructor used internally in this class. The arguments match exactly the values of the respective member variables.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator= | ( | const Iterator< BlockVectorType, constness > & | c | ) |
Copy operator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator* | ( | ) | const |
Dereferencing operator. If the template argument constness
is true
, then no writing to the result is possible, making this a const_iterator.
dereference_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator[] | ( | const difference_type | d | ) | const |
Random access operator, grant access to arbitrary elements relative to the one presently pointed to.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator++ | ( | ) |
Prefix increment operator. This operator advances the iterator to the next element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator++ | ( | int | ) |
Postfix increment operator. This operator advances the iterator to the next element and returns a copy of the old value of this iterator.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator-- | ( | ) |
Prefix decrement operator. This operator retracts the iterator to the previous element and returns a reference to *this
.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator-- | ( | int | ) |
Postfix decrement operator. This operator retracts the iterator to the previous element and returns a copy of the old value of this iterator.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator== | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Compare for equality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator== | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator!= | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Compare for inequality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator!= | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator< | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Check whether this iterators points to an element previous to the one pointed to by the given argument. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator< | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator<= | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator<= | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator> | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator> | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator>= | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Comparison operator alike to the one above.
bool internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator>= | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but compare with an iterator of different constness.
difference_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator- | ( | const Iterator< BlockVectorType, constness > & | i | ) | const |
Return the distance between the two iterators, in elements.
difference_type internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator- | ( | const InverseConstnessIterator< BlockVectorType, constness > & | i | ) | const |
Same, but for iterators of opposite constness.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator+ | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements in front of the present one.
Iterator internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator- | ( | const difference_type & | d | ) | const |
Return an iterator which is the given number of elements behind the present one.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator+= | ( | const difference_type & | d | ) |
Move the iterator d
elements forward at once, and return the result.
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::operator-= | ( | const difference_type & | d | ) |
Move the iterator d
elements backward at once, and return the result.
void internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::move_forward | ( | ) | [private] |
Move forward one element.
void internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::move_backward | ( | ) | [private] |
Move backward one element.
friend class Iterator [friend] |
Mark all other instances of this template as friends. In fact, we only need the inverse constness iterator as friend, but this is something that ISO C++ does not allow to specify. If we have detected a compiler bug during configuration of the library, use a workaround that works for this particular compiler, but is not ISO C++ conforming.
BlockVector* internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::parent [private] |
Pointer to the block vector object to which this iterator points. Depending on the value of the constness
template argument of this class, this is a const
or non-const
pointer.
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::global_index [private] |
Global index of the element to which we presently point.
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::current_block [private] |
Current block and index within this block of the element presently pointed to.
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::index_within_block [private] |
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::next_break_forward [private] |
Indices of the global element address at which we have to move on to another block when moving forward and backward. These indices are kept as a cache since this is much more efficient than always asking the parent object.
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, constness >::next_break_backward [private] |