00001 //--------------------------------------------------------------------------- 00002 // @f$Id: matrix_iterator.h 25345 2012-03-31 08:37:04Z bangerth @f$ 00003 // 00004 // Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2012 by the deal.II authors 00005 // 00006 // This file is subject to QPL and may not be distributed 00007 // without copyright and license information. Please refer 00008 // to the file deal.II/doc/license.html for the text and 00009 // further information on this license. 00010 // 00011 //--------------------------------------------------------------------------- 00012 #ifndef __deal2__matrix_iterator_h 00013 #define __deal2__matrix_iterator_h 00014 00015 00016 #include <deal.II/base/config.h> 00017 #include <deal.II/base/exceptions.h> 00018 00019 DEAL_II_NAMESPACE_OPEN 00020 00032 template <class ACCESSOR> 00033 class MatrixIterator 00034 { 00035 public: 00041 typedef typename ACCESSOR::MatrixType MatrixType; 00042 00050 MatrixIterator (MatrixType *matrix, 00051 const unsigned int row = 0, 00052 const unsigned int index = 0); 00053 00065 template <class OtherAccessor> 00066 MatrixIterator(const MatrixIterator<OtherAccessor>& other); 00067 00071 MatrixIterator & operator++ (); 00072 00076 MatrixIterator operator++ (int); 00077 00081 const ACCESSOR & operator* () const; 00082 00086 const ACCESSOR * operator-> () const; 00087 00092 bool operator == (const MatrixIterator &) const; 00093 00097 bool operator != (const MatrixIterator &) const; 00098 00110 bool operator < (const MatrixIterator &) const; 00111 00117 bool operator > (const MatrixIterator &) const; 00118 00119 private: 00124 ACCESSOR accessor; 00125 00130 template <class OtherAccessor> friend class MatrixIterator; 00131 }; 00132 00133 00134 //----------------------------------------------------------------------// 00135 00136 template <class ACCESSOR> 00137 inline 00138 MatrixIterator<ACCESSOR>:: 00139 MatrixIterator (MatrixType *matrix, 00140 const unsigned int r, 00141 const unsigned int i) 00142 : 00143 accessor(matrix, r, i) 00144 {} 00145 00146 00147 template <class ACCESSOR> 00148 template <class OtherAccessor> 00149 inline 00150 MatrixIterator<ACCESSOR>:: 00151 MatrixIterator (const MatrixIterator<OtherAccessor>& other) 00152 : 00153 accessor(other.accessor) 00154 {} 00155 00156 00157 template <class ACCESSOR> 00158 inline 00159 MatrixIterator<ACCESSOR> & 00160 MatrixIterator<ACCESSOR>::operator++ () 00161 { 00162 accessor.advance (); 00163 return *this; 00164 } 00165 00166 00167 template <class ACCESSOR> 00168 inline 00169 MatrixIterator<ACCESSOR> 00170 MatrixIterator<ACCESSOR>::operator++ (int) 00171 { 00172 const MatrixIterator iter = *this; 00173 accessor.advance (); 00174 return iter; 00175 } 00176 00177 00178 template <class ACCESSOR> 00179 inline 00180 const ACCESSOR & 00181 MatrixIterator<ACCESSOR>::operator* () const 00182 { 00183 return accessor; 00184 } 00185 00186 00187 template <class ACCESSOR> 00188 inline 00189 const ACCESSOR * 00190 MatrixIterator<ACCESSOR>::operator-> () const 00191 { 00192 return &accessor; 00193 } 00194 00195 00196 template <class ACCESSOR> 00197 inline 00198 bool 00199 MatrixIterator<ACCESSOR>:: 00200 operator == (const MatrixIterator& other) const 00201 { 00202 return (accessor == other.accessor); 00203 } 00204 00205 00206 template <class ACCESSOR> 00207 inline 00208 bool 00209 MatrixIterator<ACCESSOR>:: 00210 operator != (const MatrixIterator& other) const 00211 { 00212 return ! (*this == other); 00213 } 00214 00215 00216 template <class ACCESSOR> 00217 inline 00218 bool 00219 MatrixIterator<ACCESSOR>:: 00220 operator < (const MatrixIterator& other) const 00221 { 00222 Assert (&accessor.get_matrix() == &other.accessor.get_matrix(), 00223 ExcInternalError()); 00224 00225 return (accessor < other.accessor); 00226 } 00227 00228 00229 template <class ACCESSOR> 00230 inline 00231 bool 00232 MatrixIterator<ACCESSOR>:: 00233 operator > (const MatrixIterator& other) const 00234 { 00235 return (other < *this); 00236 } 00237 00238 DEAL_II_NAMESPACE_CLOSE 00239 00240 #endif 00241
documentation generated on Tue May 22 2012 12:06:11 by
doxygen
1.7.3