Reference documentation for deal.II version Git fcdb0c0ec9 2020-08-03 17:46:58 +0200
\(\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 - 2019 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 
32 template <class ACCESSOR>
34 {
35 public:
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 
113 private:
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 
127 template <class ACCESSOR>
129  const size_type r,
130  const size_type i)
131  : accessor(matrix, r, i)
132 {}
133 
134 
135 template <class ACCESSOR>
136 template <class OtherAccessor>
138  const MatrixIterator<OtherAccessor> &other)
139  : accessor(other.accessor)
140 {}
141 
142 
143 template <class ACCESSOR>
146 {
147  accessor.advance();
148  return *this;
149 }
150 
151 
152 template <class ACCESSOR>
155 {
156  const MatrixIterator iter = *this;
157  accessor.advance();
158  return iter;
159 }
160 
161 
162 template <class ACCESSOR>
163 inline const ACCESSOR &MatrixIterator<ACCESSOR>::operator*() const
164 {
165  return accessor;
166 }
167 
168 
169 template <class ACCESSOR>
170 inline const ACCESSOR *MatrixIterator<ACCESSOR>::operator->() const
171 {
172  return &accessor;
173 }
174 
175 
176 template <class ACCESSOR>
177 inline bool
179 {
180  return (accessor == other.accessor);
181 }
182 
183 
184 template <class ACCESSOR>
185 inline bool
187 {
188  return !(*this == other);
189 }
190 
191 
192 template <class ACCESSOR>
193 inline bool
195 {
196  Assert(&accessor.get_matrix() == &other.accessor.get_matrix(),
197  ExcInternalError());
198 
199  return (accessor < other.accessor);
200 }
201 
202 
203 template <class ACCESSOR>
204 inline bool
206 {
207  return (other < *this);
208 }
209 
211 
212 #endif
bool operator<(const MatrixIterator &) const
bool operator!=(const MatrixIterator &) const
Contents is actually a matrix.
typename ACCESSOR::MatrixType MatrixType
friend class MatrixIterator
const ACCESSOR & operator*() const
#define Assert(cond, exc)
Definition: exceptions.h:1411
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:363
MatrixIterator & operator++()
unsigned int global_dof_index
Definition: types.h:76
bool operator>(const MatrixIterator &) const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:362
const ACCESSOR * operator->() const
bool operator==(const MatrixIterator &) const
static ::ExceptionBase & ExcInternalError()