Reference documentation for deal.II version 9.1.0-pre
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness > Class Template Reference

#include <deal.II/lac/block_vector_base.h>

Public Types

using size_type = types::global_dof_index
 
using value_type = typename Types< BlockVectorType, Constness >::value_type
 
using iterator_category = std::random_access_iterator_tag
 
using BlockVector = typename Types< BlockVectorType, Constness >::BlockVector
 

Public Member Functions

 Iterator (BlockVector &parent, const size_type global_index)
 
 Iterator (const Iterator< BlockVectorType,!Constness > &c)
 
 Iterator (const Iterator &c)
 
Iteratoroperator= (const Iterator &c)
 
dereference_type operator* () const
 
dereference_type operator[] (const difference_type d) const
 
Iteratoroperator++ ()
 
Iterator operator++ (int)
 
Iteratoroperator-- ()
 
Iterator operator-- (int)
 
template<bool OtherConstness>
bool operator== (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
bool operator!= (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
bool operator< (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
bool operator<= (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
bool operator> (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
bool operator>= (const Iterator< BlockVectorType, OtherConstness > &i) const
 
template<bool OtherConstness>
difference_type operator- (const Iterator< BlockVectorType, OtherConstness > &i) const
 
Iterator operator+ (const difference_type &d) const
 
Iterator operator- (const difference_type &d) const
 
Iteratoroperator+= (const difference_type &d)
 
Iteratoroperator-= (const difference_type &d)
 

Static Public Member Functions

static::ExceptionBase & ExcPointerToDifferentVectors ()
 

Private Member Functions

 Iterator (BlockVector &parent, const size_type global_index, const size_type current_block, const size_type index_within_block, const size_type next_break_forward, const size_type next_break_backward)
 
void move_forward ()
 
void move_backward ()
 

Private Attributes

BlockVectorparent
 
size_type global_index
 
unsigned int current_block
 
size_type next_break_forward
 

Friends

template<typename , bool >
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.

Author
Wolfgang Bangerth, 2001

Definition at line 217 of file block_vector_base.h.

Member Typedef Documentation

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::size_type = types::global_dof_index

Declare the type for container size.

Definition at line 223 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::value_type = typename Types<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.

Definition at line 230 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::iterator_category = std::random_access_iterator_tag

Declare some alias which are standard for iterators and are used by algorithms to enquire about the specifics of the iterators they work on.

Definition at line 237 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::BlockVector = typename Types<BlockVectorType, Constness>::BlockVector

Typedef the type of the block vector (which differs in constness, depending on the second template parameter).

Definition at line 250 of file block_vector_base.h.

Constructor & Destructor Documentation

template<class BlockVectorType, bool Constness>
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator ( BlockVector parent,
const size_type  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.

template<class BlockVectorType, bool Constness>
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator ( const Iterator< BlockVectorType,!Constness > &  c)

Copy constructor from an iterator of different constness.

Note
Constructing a non-const iterator from a const iterator does not make sense. Attempting this will result in a compile-time error (via static_assert).
template<class BlockVectorType, bool Constness>
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator ( const Iterator< BlockVectorType, Constness > &  c)

Copy constructor from an iterator with the same constness.

template<class BlockVectorType, bool Constness>
internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::Iterator ( BlockVector parent,
const size_type  global_index,
const size_type  current_block,
const size_type  index_within_block,
const size_type  next_break_forward,
const size_type  next_break_backward 
)
private

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>
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator= ( const Iterator< BlockVectorType, Constness > &  c)

Copy operator.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator== ( const Iterator< BlockVectorType, OtherConstness > &  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.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator!= ( const Iterator< BlockVectorType, OtherConstness > &  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.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator< ( const Iterator< BlockVectorType, OtherConstness > &  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.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator<= ( const Iterator< BlockVectorType, OtherConstness > &  i) const

Comparison operator alike to the one above.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator> ( const Iterator< BlockVectorType, OtherConstness > &  i) const

Comparison operator alike to the one above.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
bool internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator>= ( const Iterator< BlockVectorType, OtherConstness > &  i) const

Comparison operator alike to the one above.

template<class BlockVectorType, bool Constness>
template<bool OtherConstness>
difference_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator- ( const Iterator< BlockVectorType, OtherConstness > &  i) const

Return the distance between the two iterators, in elements.

template<class BlockVectorType, bool 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.

template<class BlockVectorType, bool Constness>
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.

template<class BlockVectorType, bool Constness>
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator+= ( const difference_type &  d)

Move the iterator d elements forward at once, and return the result.

template<class BlockVectorType, bool Constness>
Iterator& internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::operator-= ( const difference_type &  d)

Move the iterator d elements backward at once, and return the result.

template<class BlockVectorType, bool Constness>
void internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::move_forward ( )
private

Move forward one element.

template<class BlockVectorType, bool Constness>
void internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::move_backward ( )
private

Move backward one element.

Friends And Related Function Documentation

template<class BlockVectorType, bool Constness>
template<typename , bool >
friend class Iterator
friend

Mark all other instances of this template as friends.

Definition at line 481 of file block_vector_base.h.

Member Data Documentation

template<class BlockVectorType, bool Constness>
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.

Definition at line 441 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
size_type internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::global_index
private

Global index of the element to which we presently point.

Definition at line 446 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
unsigned int internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::current_block
private

Current block and index within this block of the element presently pointed to.

Definition at line 452 of file block_vector_base.h.

template<class BlockVectorType, bool Constness>
size_type 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.

Definition at line 461 of file block_vector_base.h.


The documentation for this class was generated from the following file: