Reference documentation for deal.II version Git 7026f387cc 2019-10-15 14:19:01 -0400
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
matrix_iterator.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2018 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 
22 #include <deal.II/base/exceptions.h>
23 
24 DEAL_II_NAMESPACE_OPEN
25 
34 template <class ACCESSOR>
36 {
37 public:
42 
46  using MatrixType = typename ACCESSOR::MatrixType;
47 
52  MatrixIterator(MatrixType * matrix,
53  const size_type row = 0,
54  const size_type index = 0);
55 
62  template <class OtherAccessor>
64 
69  operator++();
70 
75  operator++(int);
76 
80  const ACCESSOR &operator*() const;
81 
85  const ACCESSOR *operator->() const;
86 
90  bool
91  operator==(const MatrixIterator &) const;
92 
96  bool
97  operator!=(const MatrixIterator &) const;
98 
105  bool
106  operator<(const MatrixIterator &) const;
107 
112  bool
113  operator>(const MatrixIterator &) const;
114 
115 private:
119  ACCESSOR accessor;
120 
121  // Allow other iterators access to private data.
122  template <class OtherAccessor>
123  friend class MatrixIterator;
124 };
125 
126 
127 //----------------------------------------------------------------------//
128 
129 template <class ACCESSOR>
131  const size_type r,
132  const size_type i)
133  : accessor(matrix, r, i)
134 {}
135 
136 
137 template <class ACCESSOR>
138 template <class OtherAccessor>
140  const MatrixIterator<OtherAccessor> &other)
141  : accessor(other.accessor)
142 {}
143 
144 
145 template <class ACCESSOR>
148 {
149  accessor.advance();
150  return *this;
151 }
152 
153 
154 template <class ACCESSOR>
157 {
158  const MatrixIterator iter = *this;
159  accessor.advance();
160  return iter;
161 }
162 
163 
164 template <class ACCESSOR>
165 inline const ACCESSOR &MatrixIterator<ACCESSOR>::operator*() const
166 {
167  return accessor;
168 }
169 
170 
171 template <class ACCESSOR>
172 inline const ACCESSOR *MatrixIterator<ACCESSOR>::operator->() const
173 {
174  return &accessor;
175 }
176 
177 
178 template <class ACCESSOR>
179 inline bool
181 {
182  return (accessor == other.accessor);
183 }
184 
185 
186 template <class ACCESSOR>
187 inline bool
189 {
190  return !(*this == other);
191 }
192 
193 
194 template <class ACCESSOR>
195 inline bool
197 {
198  Assert(&accessor.get_matrix() == &other.accessor.get_matrix(),
199  ExcInternalError());
200 
201  return (accessor < other.accessor);
202 }
203 
204 
205 template <class ACCESSOR>
206 inline bool
208 {
209  return (other < *this);
210 }
211 
212 DEAL_II_NAMESPACE_CLOSE
213 
214 #endif
bool operator<(const MatrixIterator &) const
bool operator!=(const MatrixIterator &) const
typename ACCESSOR::MatrixType MatrixType
const ACCESSOR & operator*() const
#define Assert(cond, exc)
Definition: exceptions.h:1407
MatrixIterator & operator++()
types::global_dof_index size_type
unsigned int global_dof_index
Definition: types.h:89
bool operator>(const MatrixIterator &) const
const ACCESSOR * operator->() const
bool operator==(const MatrixIterator &) const
static ::ExceptionBase & ExcInternalError()