SkelGIS  3.0
/home/helene/Documents/These/SkelGIS/SkelGIS_Library/SkelGIS_V3/skelgis/iterators/DMatrix/iterator_rev.hpp
Go to the documentation of this file.
00001 /*! \file iterator_rev.hpp
00002  *  \brief Reverse iterator object definition. Two template specializations. This iterator has to be used for contiguous and reverse moves in memory, element by element from the last element to the first element in the DMatrix. Users do not have to construct an iterator object directly (these objects are constructed in the DMatrix) however operators and methods of the iterator are used by the user.
00003  */
00004 #ifndef ITERATOR_REV_H
00005 #define ITERATOR_REV_H
00006 
00007 namespace skelgis{
00008 
00009   //================================================================================
00010   //!  Iterator reverse class
00011   /*!
00012     template of the reverse iterator of SkelGIS. This is the first specialization of iterator class.
00013     \tparam T is the type of data stored in the DMatrix to manipulate with the iterator
00014     \tparam R is the overlap distance needed by the calculation, and the same overlap than in the DMatrix to manipulate with this iterator.
00015   */
00016   //-------------------------------------------------------------------------------
00017   template<class T,int R> struct iterator_rev
00018   //-------------------------------------------------------------------------------
00019   {
00020   public:
00021     unsigned int _rank; /*!< current rank of the iterator */
00022     unsigned int _width; /*!< width of the DMatrix associated to this iterator */
00023 
00024     //! default constructor of the iterator
00025     //-------------------------------------------------------------------------------
00026     iterator_rev():_rank(0),_width(0){}
00027     //-------------------------------------------------------------------------------
00028     //! constructor of the iterator
00029     /*!
00030       \param r is the initial rank to assign to the iterator
00031       \param w is the DMatrix width to assign to the iterator
00032     */
00033     //-------------------------------------------------------------------------------
00034     iterator_rev(const unsigned int r,const unsigned int w):_rank(r),_width(w){}
00035     //-------------------------------------------------------------------------------
00036     //! constructor of the iterator from another iterator
00037     /*!
00038       \param it is the other iterator instance from which to construct the new one
00039     */
00040     //-------------------------------------------------------------------------------
00041     iterator_rev(const iterator_rev<T,R>& it):_rank(it._rank),_width(it._width){}
00042     //-------------------------------------------------------------------------------
00043     //! Destructor of the iterator
00044     //-------------------------------------------------------------------------------
00045     ~iterator_rev(){}
00046     //-------------------------------------------------------------------------------
00047     //! operator ++ pre-incrementation of the iterator
00048     /*!
00049       This operation increments the position of the iterator in the DMatrix.
00050       \return a reference to the resulting iterator itself
00051     */
00052     //-------------------------------------------------------------------------------
00053     iterator_rev<T,R>& operator++()
00054     //-------------------------------------------------------------------------------
00055     {
00056       if((_rank-1)%_width<R)
00057         _rank = _rank - 2*R -1;
00058       else
00059         --_rank;
00060 
00061       return *this;
00062     }
00063     //-------------------------------------------------------------------------------
00064     //! operator ++ post-incrementation of the iterator
00065     /*!
00066       This operation increments the position of the iterator in the DMatrix.
00067       \return a reference to the resulting iterator itself
00068     */
00069     //-------------------------------------------------------------------------------
00070     iterator_rev<T,R>& operator++(int)
00071     //-------------------------------------------------------------------------------
00072     {
00073       iterator_rev<T,R> _tmp = *this;
00074       if((_rank-1)%_width<R)
00075         _rank = _rank - 2*R -1;
00076       else
00077         --_rank;
00078 
00079       return _tmp;
00080     }
00081     //-------------------------------------------------------------------------------
00082     //! operator = of the iterator
00083     /*!
00084       This operation assigns another iterator informations to the current one.
00085       \return a reference to the resulting iterator itself
00086     */
00087     //-------------------------------------------------------------------------------
00088     inline iterator_rev<T,R>& operator=(iterator_rev<T,R> right)
00089     //-------------------------------------------------------------------------------
00090     {
00091       _rank = right._rank;
00092       _width = right._width;
00093       return *this;
00094     }
00095     //-------------------------------------------------------------------------------
00096     //! operator == of the iterator
00097     /*!
00098       This operation checks the equality of two iterators with their rank values.
00099       \return true if the two iterator have the same rank. False otherwize.
00100     */
00101     //-------------------------------------------------------------------------------
00102     inline bool operator==(const iterator_rev<T,R> & toTest) {return _rank==toTest._rank;}
00103     //-------------------------------------------------------------------------------
00104     //! operator != of the iterator
00105     /*!
00106       This operation checks the inequality of two iterators with their rank values.
00107       \return true if the two iterator do not have the same rank. False otherwize.
00108     */
00109     //-------------------------------------------------------------------------------
00110     inline bool operator!=(const iterator_rev<T,R>& toTest) {return _rank!=toTest._rank;}
00111     //-------------------------------------------------------------------------------
00112     //! operator <= of the iterator
00113     /*!
00114       This operation checks if the current iterator rank is smaller or equal to the other one.
00115       \return true is the current iterator rank is smaller or equal. False otherwize.
00116     */
00117     //-------------------------------------------------------------------------------
00118     inline bool operator <=(const iterator_rev<T,R>& toComp) {return _rank>=toComp._rank;}
00119     //-------------------------------------------------------------------------------
00120     //! operator < of the iterator
00121     /*!
00122       This operation checks if the current iterator rank is smaller than the other one.
00123       \return true is the current iterator rank is smaller. False otherwize.
00124     */
00125     //-------------------------------------------------------------------------------
00126     inline bool operator <(const iterator_rev<T,R> & toComp) {return _rank>toComp._rank;}
00127     //-------------------------------------------------------------------------------
00128     //! operator >= of the iterator
00129     /*!
00130       This operation checks if the current iterator rank is biger or equal to the other one.
00131       \return true is the current iterator rank is biger or equal. False otherwize.
00132     */
00133     //------------------------------------------------------------------------------
00134     inline bool operator >=(const iterator_rev<T,R>& toComp) {return _rank<=toComp._rank;}
00135     //-------------------------------------------------------------------------------
00136     //! operator > of the iterator
00137     /*!
00138       This operation checks if the current iterator rank is biger than the other one.
00139       \return true is the current iterator rank is biger. False otherwize.
00140     */
00141     //-------------------------------------------------------------------------------
00142     inline bool operator >(const iterator_rev<T,R> & toComp) {return _rank<toComp._rank;}
00143     //-------------------------------------------------------------------------------
00144   };
00145 
00146   //================================================================================
00147   //!  Iterator class
00148   /*!
00149     template of the reverse iterator of SkelGIS. This is the second specialization of iterator class.
00150     \tparam T is the type of data stored in the DMatrix to manipulate with the iterator
00151     R is specialized with the value 0
00152   */
00153   //-------------------------------------------------------------------------------
00154   template<class T> struct iterator_rev<T,0>
00155   //-------------------------------------------------------------------------------
00156   {
00157   public:
00158     unsigned int _rank; /*!< current rank of the iterator */
00159 
00160     //! default constructor of the iterator
00161     //-------------------------------------------------------------------------------
00162     iterator_rev():_rank(0){}
00163     //-------------------------------------------------------------------------------
00164     //! constructor of the iterator
00165     /*!
00166       \param r is the initial rank to assign to the iterator
00167     */
00168     //-------------------------------------------------------------------------------
00169     iterator_rev(const unsigned int r):_rank(r){}
00170     //-------------------------------------------------------------------------------
00171     //! constructor of the iterator from another iterator
00172     /*!
00173       \param it is the other iterator instance from which to construct the new one
00174     */
00175     //-------------------------------------------------------------------------------
00176     iterator_rev(const iterator_rev<T,0>& it):_rank(it._rank){}
00177     //-------------------------------------------------------------------------------
00178     //! Destructor of the iterator
00179     //-------------------------------------------------------------------------------
00180     ~iterator_rev(){}
00181     //-------------------------------------------------------------------------------
00182     //! operator ++ pre-incrementation of the iterator
00183     /*!
00184       This operation increments the position of the iterator in the DMatrix.
00185       \return a reference to the resulting iterator itself
00186     */
00187     //------------------------------------------------------------------------------
00188     iterator_rev<T,0>& operator++(){--_rank;return *this;}
00189     //-------------------------------------------------------------------------------
00190     //! operator ++ post-incrementation of the iterator
00191     /*!
00192       This operation increments the position of the iterator in the DMatrix.
00193       \return a reference to the resulting iterator itself
00194     */
00195     //-------------------------------------------------------------------------------
00196     iterator_rev<T,0>& operator++(int){iterator_rev<T,0> _tmp = *this;--_rank;return _tmp;}
00197     //-------------------------------------------------------------------------------
00198     //! operator = of the iterator
00199     /*!
00200       This operation assigns another iterator informations to the current one.
00201       \return a reference to the resulting iterator itself
00202     */
00203     //-------------------------------------------------------------------------------
00204     inline iterator_rev<T,0>& operator=(iterator_rev<T,0> right)
00205     //-------------------------------------------------------------------------------
00206     {
00207       _rank = right._rank;
00208       return *this;
00209     }
00210     //-------------------------------------------------------------------------------
00211     //! operator == of the iterator
00212     /*!
00213       This operation checks the equality of two iterators with their rank values.
00214       \return true if the two iterator have the same rank. False otherwize.
00215     */
00216     //-------------------------------------------------------------------------------
00217     inline bool operator==(const iterator_rev<T,0>& toTest) {return _rank==toTest._rank;}
00218     //-------------------------------------------------------------------------------
00219     //! operator != of the iterator
00220     /*!
00221       This operation checks the inequality of two iterators with their rank values.
00222       \return true if the two iterator do not have the same rank. False otherwize.
00223     */
00224     //-------------------------------------------------------------------------------
00225     inline bool operator!=(const iterator_rev<T,0>& toTest) {return _rank!=toTest._rank;}
00226     //-------------------------------------------------------------------------------
00227     //! operator <= of the iterator
00228     /*!
00229       This operation checks if the current iterator rank is smaller or equal to the other one.
00230       \return true is the current iterator rank is smaller or equal. False otherwize.
00231     */
00232     //-------------------------------------------------------------------------------
00233     inline bool operator <=(const iterator_rev<T,0>& toComp) {return _rank>=toComp._rank;}
00234     //! operator < of the iterator
00235     /*!
00236       This operation checks if the current iterator rank is smaller than the other one.
00237       \return true is the current iterator rank is smaller. False otherwize.
00238     */
00239     //-------------------------------------------------------------------------------
00240     inline bool operator <(const iterator_rev<T,0>& toComp) {return _rank>toComp._rank;}
00241     //-------------------------------------------------------------------------------
00242     //! operator >= of the iterator
00243     /*!
00244       This operation checks if the current iterator rank is biger or equal to the other one.
00245       \return true is the current iterator rank is biger or equal. False otherwize.
00246     */
00247     //------------------------------------------------------------------------------
00248     inline bool operator >=(const iterator_rev<T,0>& toComp) {return _rank<=toComp._rank;}
00249     //-------------------------------------------------------------------------------
00250     //! operator > of the iterator
00251     /*!
00252       This operation checks if the current iterator rank is biger than the other one.
00253       \return true is the current iterator rank is biger. False otherwize.
00254     */
00255     //-------------------------------------------------------------------------------
00256     inline bool operator >(const iterator_rev<T,0>& toComp) {return _rank<toComp._rank;}
00257     //-------------------------------------------------------------------------------
00258   };
00259   //-------------------------------------------------------------------------------
00260 }
00261 
00262 #endif
00263 
00264 
00265 
00266 
 All Classes Files Functions Variables Defines