internal::BlockVectorIterators::Iterator< BlockVectorType, constness > Class Template Reference
List of all members.
Classes |
class | ExcCastingAwayConstness |
class | ExcPointerToDifferentVectors |
Public Types |
typedef Types< BlockVectorType,
constness >::value_type | value_type |
typedef
std::random_access_iterator_tag | iterator_type |
typedef ptrdiff_t | difference_type |
typedef BlockVectorType::reference | reference |
typedef value_type * | pointer |
typedef Types< BlockVectorType,
constness >::dereference_type | dereference_type |
typedef Types< BlockVectorType,
constness >::BlockVector | BlockVector |
Public Member Functions |
| Iterator (BlockVector &parent, const unsigned int global_index) |
| Iterator (const Iterator< BlockVectorType, constness > &c) |
| Iterator (const InverseConstnessIterator &c) |
Iterator & | operator= (const Iterator &c) |
dereference_type | operator* () const |
dereference_type | operator[] (const difference_type d) const |
Iterator & | operator++ () |
Iterator | operator++ (int) |
Iterator & | operator-- () |
Iterator | operator-- (int) |
bool | operator== (const Iterator &i) const |
bool | operator== (const InverseConstnessIterator &i) const |
bool | operator!= (const Iterator &i) const |
bool | operator!= (const InverseConstnessIterator &i) const |
bool | operator< (const Iterator &i) const |
bool | operator< (const InverseConstnessIterator &i) const |
bool | operator<= (const Iterator &i) const |
bool | operator<= (const InverseConstnessIterator &i) const |
bool | operator> (const Iterator &i) const |
bool | operator> (const InverseConstnessIterator &i) const |
bool | operator>= (const Iterator &i) const |
bool | operator>= (const InverseConstnessIterator &i) const |
difference_type | operator- (const Iterator &i) const |
difference_type | operator- (const InverseConstnessIterator &i) const |
Iterator | operator+ (const difference_type &d) const |
Iterator | operator- (const difference_type &d) const |
Iterator & | operator+= (const difference_type &d) |
Iterator & | operator-= (const difference_type &d) |
Private Types |
typedef Iterator
< BlockVectorType,!constness > | InverseConstnessIterator |
Private Member Functions |
| 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) |
void | move_forward () |
void | move_backward () |
Private Attributes |
BlockVector * | parent |
unsigned int | global_index |
unsigned int | current_block |
unsigned int | index_within_block |
unsigned int | next_break_forward |
unsigned int | next_break_backward |
Friends |
class | Iterator |
Detailed Description
template<class BlockVectorType, bool constness>
class internal::BlockVectorIterators::Iterator< BlockVectorType, constness >
General random-access iterator class for block vectors. Since we do not want to have two classes for non-const iterator and const_iterator, we take a second template argument which denotes whether the vector we point into is a constant object or not. The first template argument is always the number type of the block vector in use.
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.
- Author:
- Wolfgang Bangerth, 2001
Member Typedef Documentation
template<class BlockVectorType, bool constness>
Typedef an iterator with opposite constness requirements on the elements it points to.
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
Declare some typedefs which are standard for iterators and are used by algorithms to enquire about the specifics of the iterators they work on.
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
Typedef the type of the block vector (which differs in constness, depending on the second template parameter).
Constructor & Destructor Documentation
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
Constructor used internally in this class. The arguments match exactly the values of the respective member variables.
Member Function Documentation
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
Dereferencing operator. If the template argument constness
is true
, then no writing to the result is possible, making this a const_iterator.
template<class BlockVectorType, bool constness>
Random access operator, grant access to arbitrary elements relative to the one presently pointed to.
template<class BlockVectorType, bool constness>
Prefix increment operator. This operator advances the iterator to the next element and returns a reference to *this
.
template<class BlockVectorType, bool constness>
Postfix increment operator. This operator advances the iterator to the next element and returns a copy of the old value of this iterator.
template<class BlockVectorType, bool constness>
Prefix decrement operator. This operator retracts the iterator to the previous element and returns a reference to *this
.
template<class BlockVectorType, bool constness>
Postfix decrement operator. This operator retracts the iterator to the previous element and returns a copy of the old value of this iterator.
template<class BlockVectorType, bool constness>
Compare for equality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
Compare for inequality of iterators. This operator checks whether the vectors pointed to are the same, and if not it throws an exception.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
Comparison operator alike to the one above.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
Comparison operator alike to the one above.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
Comparison operator alike to the one above.
template<class BlockVectorType, bool constness>
Same, but compare with an iterator of different constness.
template<class BlockVectorType, bool constness>
Return the distance between the two iterators, in elements.
template<class BlockVectorType, bool constness>
Same, but for iterators of opposite constness.
template<class BlockVectorType, bool constness>
Return an iterator which is the given number of elements in front of the present one.
template<class BlockVectorType, bool constness>
Return an iterator which is the given number of elements behind the present one.
template<class BlockVectorType, bool constness>
Move the iterator d
elements forward at once, and return the result.
template<class BlockVectorType, bool constness>
Move the iterator d
elements backward at once, and return the result.
template<class BlockVectorType, bool constness>
Move forward one element.
template<class BlockVectorType, bool constness>
Move backward one element.
Friends And Related Function Documentation
template<class BlockVectorType, bool constness>
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.
Member Data Documentation
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
Global index of the element to which we presently point.
template<class BlockVectorType, bool constness>
Current block and index within this block of the element presently pointed to.
template<class BlockVectorType, bool constness>
template<class BlockVectorType, bool constness>
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.
template<class BlockVectorType, bool constness>
The documentation for this class was generated from the following file: