Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
No Matches
Public Member Functions | Private Attributes | List of all members
DynamicSparsityPatternIterators::Iterator Class Reference

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

Public Member Functions

 Iterator (const DynamicSparsityPattern *sp, const size_type row, const unsigned int index_within_row)
 Iterator (const DynamicSparsityPattern *sp)
 Iterator ()=default
Iteratoroperator++ ()
Iterator operator++ (int)
const Accessoroperator* () const
const Accessoroperator-> () const
bool operator== (const Iterator &) const
bool operator!= (const Iterator &) const
bool operator< (const Iterator &) const
int operator- (const Iterator &p) const

Private Attributes

Accessor accessor

Detailed Description

An iterator class for walking over the elements of a sparsity pattern.

The typical use for these iterators is to iterate over the elements of a sparsity pattern (or, since they also serve as the basis for iterating over the elements of an associated matrix, over the elements of a sparse matrix), or over the elements of individual rows. There is no guarantee that the elements of a row are actually traversed in an order in which column numbers monotonically increase. See the documentation of the SparsityPattern class for more information.

This class operates directly on the internal data structures of the DynamicSparsityPattern class. As a consequence, some operations are cheap and some are not. In particular, it is cheap to access the column index of the sparsity pattern entry pointed to. On the other hand, it is expensive to compute the distance between two iterators. As a consequence, when you design algorithms that use these iterators, it is common practice to not loop over all elements of a sparsity pattern at once, but to have an outer loop over all rows and within this loop iterate over the elements of this row. This way, you only ever need to dereference the iterator to obtain the column indices whereas the (expensive) lookup of the row index can be avoided by using the loop index instead.

Definition at line 190 of file dynamic_sparsity_pattern.h.

Constructor & Destructor Documentation

◆ Iterator() [1/3]

DynamicSparsityPatternIterators::Iterator::Iterator ( const DynamicSparsityPattern sp,
const size_type  row,
const unsigned int  index_within_row 

Constructor. Create an iterator into the sparsity pattern sp for the given global index (i.e., the index of the given element counting from the zeroth row).

Definition at line 894 of file dynamic_sparsity_pattern.h.

◆ Iterator() [2/3]

DynamicSparsityPatternIterators::Iterator::Iterator ( const DynamicSparsityPattern sp)

Constructor. Create an invalid (end) iterator into the sparsity pattern sp.

Definition at line 902 of file dynamic_sparsity_pattern.h.

◆ Iterator() [3/3]

DynamicSparsityPatternIterators::Iterator::Iterator ( )

Default constructor creating an invalid iterator. This constructor is here only to be able to store iterators in STL containers such as std::vector.

Member Function Documentation

◆ operator++() [1/2]

Iterator & DynamicSparsityPatternIterators::Iterator::operator++ ( )

Prefix increment.

Definition at line 909 of file dynamic_sparsity_pattern.h.

◆ operator++() [2/2]

Iterator DynamicSparsityPatternIterators::Iterator::operator++ ( int  )

Postfix increment.

Definition at line 918 of file dynamic_sparsity_pattern.h.

◆ operator*()

const Accessor & DynamicSparsityPatternIterators::Iterator::operator* ( ) const

Dereferencing operator.

Definition at line 928 of file dynamic_sparsity_pattern.h.

◆ operator->()

const Accessor * DynamicSparsityPatternIterators::Iterator::operator-> ( ) const

Dereferencing operator.

Definition at line 936 of file dynamic_sparsity_pattern.h.

◆ operator==()

bool DynamicSparsityPatternIterators::Iterator::operator== ( const Iterator other) const

Comparison. True, if both iterators point to the same matrix position.

Definition at line 943 of file dynamic_sparsity_pattern.h.

◆ operator!=()

bool DynamicSparsityPatternIterators::Iterator::operator!= ( const Iterator other) const

Inverse of ==.

Definition at line 951 of file dynamic_sparsity_pattern.h.

◆ operator<()

bool DynamicSparsityPatternIterators::Iterator::operator< ( const Iterator other) const

Comparison operator. Result is true if either the first row number is smaller or if the row numbers are equal and the first index is smaller.

This function is only valid if both iterators point into the same matrix.

Definition at line 957 of file dynamic_sparsity_pattern.h.

◆ operator-()

int DynamicSparsityPatternIterators::Iterator::operator- ( const Iterator p) const

Return the distance between the current iterator and the argument. The distance is given by how many times one has to apply operator++ to the current iterator to get the argument (for a positive return value), or operator-- (for a negative return value).

Definition at line 965 of file dynamic_sparsity_pattern.h.

Member Data Documentation

◆ accessor

Accessor DynamicSparsityPatternIterators::Iterator::accessor

Store an object of the accessor class.

Definition at line 274 of file dynamic_sparsity_pattern.h.

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