Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

operator/hashedSMatrixIterator.hh
Go to the documentation of this file.
00001 /* matrix iterator for hashed sparse matrices
00002  */
00003 
00004 #ifndef hSparseMatrixIterator_hh
00005 #define hSparseMatrixIterator_hh
00006 
00007 #include "matrixIterator.hh"
00008 #include "basics/debug.hh"
00009 
00010 namespace concepts {
00011 
00012   // forward declaration
00013   template<class T>
00014   class HashedSparseMatrix;
00015 
00016 //   template<class T>
00017 //   struct HashedSparseMatrix<T>::Value;
00018 
00019   // *********************************************** _HashedSMatrix_iterator **
00020 
00025   template <class _Tp, class _Ref, class _Ptr>
00026   class _HashedSMatrix_iterator : 
00027     public _Matrix_iterator_base<_Tp, _Ref, _Ptr> {
00028   public:
00029     typedef _HashedSMatrix_iterator<_Tp, _Tp&, _Tp*>            iterator;
00030     typedef _HashedSMatrix_iterator<_Tp, const _Tp&,const _Tp*> const_iterator;
00031 
00032     template<class _Tp_, class _Ref_, class _Ptr_>
00033     struct MatrixType;
00034 
00035     typedef std::forward_iterator_tag                      iterator_category;
00036     typedef _Tp                                            value_type;
00037     typedef _Ptr                                           pointer;
00038     typedef _Ref                                           reference;
00039     typedef size_t                                         size_type;
00040     typedef ptrdiff_t                                      difference_type;
00041     typedef _HashedSMatrix_iterator                        _Self;
00042     typedef _Matrix_iterator_base<_Tp, _Ref, _Ptr>         _Base;
00043     typedef typename MatrixType<_Tp, _Ref, _Ptr>::type     matrix_type;
00044     typedef typename _Base::return_type                    return_type;
00045 
00051     _HashedSMatrix_iterator(matrix_type& m, const uint r = 0);
00053     _HashedSMatrix_iterator();
00055     template<class _RefR, class _PtrR>
00056     _HashedSMatrix_iterator
00057     (const _HashedSMatrix_iterator<_Tp, _RefR, _PtrR>& __x)
00058       : _Base(__x), v_(__x.v()), hashBits_(__x.hashBits()),
00059   pPerRow_(__x.pPerRow()), nofPages_(__x.nofPages()), 
00060   p_(__x.p()), pNextRow_(__x.pNextRow()), page_(__x.page()) {
00061       conceptsAssert(v_ == 0 || v_->val != 0.0, Assertion());
00062     }
00063 
00065     /*return_type*/ reference operator*() const { 
00066       conceptsAssert(v_ != 0 && v_->val != 0.0, Assertion());
00067       return v_->val;
00068     }
00070     pointer operator->() const {
00071       conceptsAssert(v_ != 0 && v_->val != 0.0, Assertion());
00072       return &v_->val;
00073     }
00074 
00076     template<class _RefR, class _PtrR>
00077     _Self& operator=(const _HashedSMatrix_iterator<_Tp, _RefR, _PtrR>& __x) {
00078       _Base::operator=(__x);
00079       v_ = __x.v(); hashBits_ = __x.hashBits();
00080       pPerRow_ = __x.pPerRow(); nofPages_ = __x.nofPages(); 
00081       p_ = __x.p(); pNextRow_ = __x.pNextRow(); page_ = __x.page();
00082       conceptsAssert(v_ == 0 || v_->val != 0.0, Assertion());
00083       return *this;
00084     }
00085 
00087     _Self& operator++();
00088     _Self operator++(int);
00089 
00091     typename HashedSparseMatrix<_Tp>::Value* v() const { return v_; }
00092     int hashBits() const { return hashBits_; }
00093     int pPerRow() const { return pPerRow_; }
00094     int nofPages() const { return nofPages_; }
00095     int p() const { return p_; }
00096     int pNextRow() const { return pNextRow_; }
00097     typename HashedSparseMatrix<_Tp>::Value** page() const { return page_; }
00098   protected:
00099     virtual std::ostream& info(std::ostream& os) const;
00100   private:
00102     typename HashedSparseMatrix<_Tp>::Value* v_;
00104     int hashBits_, pPerRow_, nofPages_;
00106     int p_, pNextRow_;
00108     typename HashedSparseMatrix<_Tp>::Value** page_;
00109   };
00110 
00112   template <class _Tp, class _Ref, class _Ptr>
00113   template<class _Tp_, class _Ref_, class _Ptr_>
00114   struct _HashedSMatrix_iterator<_Tp, _Ref, _Ptr>::MatrixType {
00115     typedef HashedSparseMatrix<_Tp_> type;
00116   };
00117 
00119   template <class _Tp, class _Ref, class _Ptr>
00120   template<class _Tp_>
00121   struct _HashedSMatrix_iterator<_Tp, _Ref, _Ptr>::
00122     MatrixType<_Tp_, const _Tp_&, const _Tp_*>
00123   {
00124     typedef const HashedSparseMatrix<_Tp_> type;
00125   };
00126 
00127 } // namespace concepts
00128 
00129 #endif // hSparseMatrixIterator_hh
00130 

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)