Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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 std::conditional< Constness, const typename BlockVectorType::value_type, typename BlockVectorType::value_type >::type
 
using iterator_category = std::random_access_iterator_tag
 
using BlockVector = typename std::conditional< Constness, const BlockVectorType, BlockVectorType >::type
 

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 ::ExceptionBaseExcPointerToDifferentVectors ()
 

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 137 of file block_vector_base.h.

Member Typedef Documentation

◆ size_type

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 143 of file block_vector_base.h.

◆ value_type

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::value_type = typename std::conditional<Constness, const typename BlockVectorType::value_type, typename BlockVectorType::value_type>::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 153 of file block_vector_base.h.

◆ iterator_category

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 160 of file block_vector_base.h.

◆ BlockVector

template<class BlockVectorType, bool Constness>
using internal::BlockVectorIterators::Iterator< BlockVectorType, Constness >::BlockVector = typename std:: conditional<Constness, const BlockVectorType, BlockVectorType>::type

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

Definition at line 175 of file block_vector_base.h.

Constructor & Destructor Documentation

◆ Iterator() [1/4]

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.

◆ Iterator() [2/4]

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).

◆ Iterator() [3/4]

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.

◆ Iterator() [4/4]

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

◆ operator=()

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

Copy operator.

◆ 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.

◆ operator[]()

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.

◆ operator++() [1/2]

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.

◆ operator++() [2/2]

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.

◆ operator--() [1/2]

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.

◆ operator--() [2/2]

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.

◆ operator==()

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.

◆ operator!=()

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.

◆ operator<()

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.

◆ operator<=()

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.

◆ operator>()

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.

◆ operator>=()

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.

◆ operator-() [1/2]

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.

◆ operator+()

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.

◆ operator-() [2/2]

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.

◆ operator+=()

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.

◆ operator-=()

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.

◆ move_forward()

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

Move forward one element.

◆ move_backward()

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

Move backward one element.

Friends And Related Function Documentation

◆ Iterator

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

Mark all other instances of this template as friends.

Definition at line 406 of file block_vector_base.h.

Member Data Documentation

◆ parent

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 366 of file block_vector_base.h.

◆ global_index

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 371 of file block_vector_base.h.

◆ current_block

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 377 of file block_vector_base.h.

◆ next_break_forward

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 386 of file block_vector_base.h.


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