Reference documentation for deal.II version 8.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
matrix_iterator.h
1 // ---------------------------------------------------------------------
2 // @f$Id: matrix_iterator.h 30036 2013-07-18 16:55:32Z maier @f$
3 //
4 // Copyright (C) 1999 - 2013 by the deal.II authors
5 //
6 // This file is part of the deal.II library.
7 //
8 // The deal.II library is free software; you can use it, redistribute
9 // it, and/or modify it under the terms of the GNU Lesser General
10 // Public License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 // The full text of the license can be found in the file LICENSE at
13 // the top level of the deal.II distribution.
14 //
15 // ---------------------------------------------------------------------
16 
17 #ifndef __deal2__matrix_iterator_h
18 #define __deal2__matrix_iterator_h
19 
20 
21 #include <deal.II/base/config.h>
23 
25 
37 template <class ACCESSOR>
38 class MatrixIterator
39 {
40 public:
45 
51  typedef typename ACCESSOR::MatrixType MatrixType;
52 
60  MatrixIterator (MatrixType *matrix,
61  const size_type row = 0,
62  const size_type index = 0);
63 
75  template <class OtherAccessor>
77 
82 
87 
91  const ACCESSOR &operator* () const;
92 
96  const ACCESSOR *operator-> () const;
97 
102  bool operator == (const MatrixIterator &) const;
103 
107  bool operator != (const MatrixIterator &) const;
108 
120  bool operator < (const MatrixIterator &) const;
121 
127  bool operator > (const MatrixIterator &) const;
128 
129 private:
134  ACCESSOR accessor;
135 
140  template <class OtherAccessor> friend class MatrixIterator;
141 };
142 
143 
144 //----------------------------------------------------------------------//
145 
146 template <class ACCESSOR>
147 inline
150  const size_type r,
151  const size_type i)
152  :
153  accessor(matrix, r, i)
154 {}
155 
156 
157 template <class ACCESSOR>
158 template <class OtherAccessor>
159 inline
162  :
163  accessor(other.accessor)
164 {}
165 
166 
167 template <class ACCESSOR>
168 inline
171 {
172  accessor.advance ();
173  return *this;
174 }
175 
176 
177 template <class ACCESSOR>
178 inline
181 {
182  const MatrixIterator iter = *this;
183  accessor.advance ();
184  return iter;
185 }
186 
187 
188 template <class ACCESSOR>
189 inline
190 const ACCESSOR &
192 {
193  return accessor;
194 }
195 
196 
197 template <class ACCESSOR>
198 inline
199 const ACCESSOR *
201 {
202  return &accessor;
203 }
204 
205 
206 template <class ACCESSOR>
207 inline
208 bool
210 operator == (const MatrixIterator &other) const
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 ! (*this == other);
223 }
224 
225 
226 template <class ACCESSOR>
227 inline
228 bool
230 operator < (const MatrixIterator &other) const
231 {
232  Assert (&accessor.get_matrix() == &other.accessor.get_matrix(),
233  ExcInternalError());
234 
235  return (accessor < other.accessor);
236 }
237 
238 
239 template <class ACCESSOR>
240 inline
241 bool
243 operator > (const MatrixIterator &other) const
244 {
245  return (other < *this);
246 }
247 
248 DEAL_II_NAMESPACE_CLOSE
249 
250 #endif
bool operator>(const MatrixIterator &) const
friend class MatrixIterator
bool operator==(const MatrixIterator &) const
MatrixIterator & operator++()
unsigned int global_dof_index
Definition: types.h:100
ACCESSOR::MatrixType MatrixType
#define Assert(cond, exc)
Definition: exceptions.h:299
types::global_dof_index size_type
const ACCESSOR & operator*() const
bool operator!=(const MatrixIterator &) const
bool operator<(const MatrixIterator &) const
const ACCESSOR * operator->() const
::ExceptionBase & ExcInternalError()