Reference documentation for deal.II version 9.3.3
\(\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\}}\)
matrix_iterator.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 1999 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_matrix_iterator_h
17#define dealii_matrix_iterator_h
18
19
20#include <deal.II/base/config.h>
21
23
25
32template <class ACCESSOR>
34{
35public:
40
44 using MatrixType = typename ACCESSOR::MatrixType;
45
51 const size_type row = 0,
52 const size_type index = 0);
53
60 template <class OtherAccessor>
62
67 operator++();
68
73 operator++(int);
74
78 const ACCESSOR &operator*() const;
79
83 const ACCESSOR *operator->() const;
84
88 bool
89 operator==(const MatrixIterator &) const;
90
94 bool
95 operator!=(const MatrixIterator &) const;
96
103 bool
104 operator<(const MatrixIterator &) const;
105
110 bool
111 operator>(const MatrixIterator &) const;
112
113private:
117 ACCESSOR accessor;
118
119 // Allow other iterators access to private data.
120 template <class OtherAccessor>
121 friend class MatrixIterator;
122};
123
124
125//----------------------------------------------------------------------//
126
127template <class ACCESSOR>
129 const size_type r,
130 const size_type i)
131 : accessor(matrix, r, i)
132{}
133
134
135template <class ACCESSOR>
136template <class OtherAccessor>
139 : accessor(other.accessor)
140{}
141
142
143template <class ACCESSOR>
146{
147 accessor.advance();
148 return *this;
149}
150
151
152template <class ACCESSOR>
155{
156 const MatrixIterator iter = *this;
157 accessor.advance();
158 return iter;
159}
160
161
162template <class ACCESSOR>
163inline const ACCESSOR &MatrixIterator<ACCESSOR>::operator*() const
164{
165 return accessor;
166}
167
168
169template <class ACCESSOR>
170inline const ACCESSOR *MatrixIterator<ACCESSOR>::operator->() const
171{
172 return &accessor;
173}
174
175
176template <class ACCESSOR>
177inline bool
179{
180 return (accessor == other.accessor);
181}
182
183
184template <class ACCESSOR>
185inline bool
187{
188 return !(*this == other);
189}
190
191
192template <class ACCESSOR>
193inline bool
195{
196 Assert(&accessor.get_matrix() == &other.accessor.get_matrix(),
198
199 return (accessor < other.accessor);
200}
201
202
203template <class ACCESSOR>
204inline bool
206{
207 return (other < *this);
208}
209
211
212#endif
MatrixIterator & operator++()
const ACCESSOR * operator->() const
bool operator!=(const MatrixIterator &) const
bool operator<(const MatrixIterator &) const
typename ACCESSOR::MatrixType MatrixType
friend class MatrixIterator
bool operator==(const MatrixIterator &) const
bool operator>(const MatrixIterator &) const
const ACCESSOR & operator*() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:402
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:403
#define Assert(cond, exc)
Definition: exceptions.h:1465
static ::ExceptionBase & ExcInternalError()
@ matrix
Contents is actually a matrix.
unsigned int global_dof_index
Definition: types.h:76