Reference documentation for deal.II version 9.0.0
matrix_iterator.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 1999 - 2017 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 at
12 // the top level of the deal.II distribution.
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 #include <deal.II/base/exceptions.h>
22 
23 DEAL_II_NAMESPACE_OPEN
24 
33 template <class ACCESSOR>
34 class MatrixIterator
35 {
36 public:
41 
45  typedef typename ACCESSOR::MatrixType MatrixType;
46 
51  MatrixIterator (MatrixType *matrix,
52  const size_type row = 0,
53  const size_type index = 0);
54 
61  template <class OtherAccessor>
63 
68 
73 
77  const ACCESSOR &operator* () const;
78 
82  const ACCESSOR *operator-> () const;
83 
87  bool operator == (const MatrixIterator &) const;
88 
92  bool operator != (const MatrixIterator &) const;
93 
100  bool operator < (const MatrixIterator &) const;
101 
106  bool operator > (const MatrixIterator &) const;
107 
108 private:
112  ACCESSOR accessor;
113 
117  template <class OtherAccessor> friend class MatrixIterator;
118 };
119 
120 
121 //----------------------------------------------------------------------//
122 
123 template <class ACCESSOR>
124 inline
127  const size_type r,
128  const size_type i)
129  :
130  accessor(matrix, r, i)
131 {}
132 
133 
134 template <class ACCESSOR>
135 template <class OtherAccessor>
136 inline
139  :
140  accessor(other.accessor)
141 {}
142 
143 
144 template <class ACCESSOR>
145 inline
148 {
149  accessor.advance ();
150  return *this;
151 }
152 
153 
154 template <class ACCESSOR>
155 inline
158 {
159  const MatrixIterator iter = *this;
160  accessor.advance ();
161  return iter;
162 }
163 
164 
165 template <class ACCESSOR>
166 inline
167 const ACCESSOR &
169 {
170  return accessor;
171 }
172 
173 
174 template <class ACCESSOR>
175 inline
176 const ACCESSOR *
178 {
179  return &accessor;
180 }
181 
182 
183 template <class ACCESSOR>
184 inline
185 bool
187 operator == (const MatrixIterator &other) const
188 {
189  return (accessor == other.accessor);
190 }
191 
192 
193 template <class ACCESSOR>
194 inline
195 bool
197 operator != (const MatrixIterator &other) const
198 {
199  return ! (*this == other);
200 }
201 
202 
203 template <class ACCESSOR>
204 inline
205 bool
207 operator < (const MatrixIterator &other) const
208 {
209  Assert (&accessor.get_matrix() == &other.accessor.get_matrix(),
210  ExcInternalError());
211 
212  return (accessor < other.accessor);
213 }
214 
215 
216 template <class ACCESSOR>
217 inline
218 bool
220 operator > (const MatrixIterator &other) const
221 {
222  return (other < *this);
223 }
224 
225 DEAL_II_NAMESPACE_CLOSE
226 
227 #endif
bool operator<(const MatrixIterator &) const
bool operator!=(const MatrixIterator &) const
friend class MatrixIterator
const ACCESSOR & operator*() const
unsigned int global_dof_index
Definition: types.h:88
ACCESSOR::MatrixType MatrixType
#define Assert(cond, exc)
Definition: exceptions.h:1142
MatrixIterator & operator++()
types::global_dof_index size_type
bool operator>(const MatrixIterator &) const
const ACCESSOR * operator->() const
bool operator==(const MatrixIterator &) const
static ::ExceptionBase & ExcInternalError()