triangular.hpp
来自「Boost provides free peer-reviewed portab」· HPP 代码 · 共 1,801 行 · 第 1/5 页
HPP
1,801 行
it1_ = it.it1_; return *this; } // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator1 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it1_ == it.it1_; } BOOST_UBLAS_INLINE bool operator < (const iterator1 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it1_ < it.it1_; } private: subiterator1_type it1_; friend class const_iterator1; };#endif BOOST_UBLAS_INLINE iterator1 begin1 () { return find1 (0, 0, 0); } BOOST_UBLAS_INLINE iterator1 end1 () { return find1 (0, size1 (), 0); }#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class const_iterator2: public container_const_reference<triangular_adaptor>, public random_access_iterator_base<typename iterator_restrict_traits< typename const_subiterator1_type::iterator_category, packed_random_access_iterator_tag>::iterator_category, const_iterator2, value_type> { public: typedef typename const_subiterator2_type::value_type value_type; typedef typename const_subiterator2_type::difference_type difference_type; typedef typename const_subiterator2_type::reference reference; typedef typename const_subiterator2_type::pointer pointer; typedef const_iterator1 dual_iterator_type; typedef const_reverse_iterator1 dual_reverse_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE const_iterator2 (): container_const_reference<self_type> (), it2_ () {} BOOST_UBLAS_INLINE const_iterator2 (const self_type &m, const const_subiterator2_type &it2): container_const_reference<self_type> (m), it2_ (it2) {} BOOST_UBLAS_INLINE const_iterator2 (const iterator2 &it): container_const_reference<self_type> (it ()), it2_ (it.it2_) {} // Arithmetic BOOST_UBLAS_INLINE const_iterator2 &operator ++ () { ++ it2_; return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator -- () { -- it2_; return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator += (difference_type n) { it2_ += n; return *this; } BOOST_UBLAS_INLINE const_iterator2 &operator -= (difference_type n) { it2_ -= n; return *this; } BOOST_UBLAS_INLINE difference_type operator - (const const_iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ - it.it2_; } // Dereference BOOST_UBLAS_INLINE const_reference operator * () const { size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); if (triangular_type::other (i, j)) return *it2_; else return (*this) () (i, j); } BOOST_UBLAS_INLINE const_reference operator [] (difference_type n) const { return *(*this + n); }#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif const_iterator1 begin () const { return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif const_iterator1 end () const { return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif const_reverse_iterator1 rbegin () const { return const_reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif const_reverse_iterator1 rend () const { return const_reverse_iterator1 (begin ()); }#endif // Indices BOOST_UBLAS_INLINE size_type index1 () const { return it2_.index1 (); } BOOST_UBLAS_INLINE size_type index2 () const { return it2_.index2 (); } // Assignment BOOST_UBLAS_INLINE const_iterator2 &operator = (const const_iterator2 &it) { container_const_reference<self_type>::assign (&it ()); it2_ = it.it2_; return *this; } // Comparison BOOST_UBLAS_INLINE bool operator == (const const_iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const const_iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ < it.it2_; } private: const_subiterator2_type it2_; };#endif BOOST_UBLAS_INLINE const_iterator2 begin2 () const { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE const_iterator2 end2 () const { return find2 (0, 0, size2 ()); }#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR class iterator2: public container_reference<triangular_adaptor>, public random_access_iterator_base<typename iterator_restrict_traits< typename subiterator1_type::iterator_category, packed_random_access_iterator_tag>::iterator_category, iterator2, value_type> { public: typedef typename subiterator2_type::value_type value_type; typedef typename subiterator2_type::difference_type difference_type; typedef typename subiterator2_type::reference reference; typedef typename subiterator2_type::pointer pointer; typedef iterator1 dual_iterator_type; typedef reverse_iterator1 dual_reverse_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE iterator2 (): container_reference<self_type> (), it2_ () {} BOOST_UBLAS_INLINE iterator2 (self_type &m, const subiterator2_type &it2): container_reference<self_type> (m), it2_ (it2) {} // Arithmetic BOOST_UBLAS_INLINE iterator2 &operator ++ () { ++ it2_; return *this; } BOOST_UBLAS_INLINE iterator2 &operator -- () { -- it2_; return *this; } BOOST_UBLAS_INLINE iterator2 &operator += (difference_type n) { it2_ += n; return *this; } BOOST_UBLAS_INLINE iterator2 &operator -= (difference_type n) { it2_ -= n; return *this; } BOOST_UBLAS_INLINE difference_type operator - (const iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ - it.it2_; } // Dereference BOOST_UBLAS_INLINE reference operator * () const { size_type i = index1 (); size_type j = index2 (); BOOST_UBLAS_CHECK (i < (*this) ().size1 (), bad_index ()); BOOST_UBLAS_CHECK (j < (*this) ().size2 (), bad_index ()); if (triangular_type::other (i, j)) return *it2_; else return (*this) () (i, j); } BOOST_UBLAS_INLINE reference operator [] (difference_type n) const { return *(*this + n); }#ifndef BOOST_UBLAS_NO_NESTED_CLASS_RELATION BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif iterator1 begin () const { return (*this) ().find1 (1, 0, index2 ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif iterator1 end () const { return (*this) ().find1 (1, (*this) ().size1 (), index2 ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif reverse_iterator1 rbegin () const { return reverse_iterator1 (end ()); } BOOST_UBLAS_INLINE#ifdef BOOST_UBLAS_MSVC_NESTED_CLASS_RELATION typename self_type::#endif reverse_iterator1 rend () const { return reverse_iterator1 (begin ()); }#endif // Indices BOOST_UBLAS_INLINE size_type index1 () const { return it2_.index1 (); } BOOST_UBLAS_INLINE size_type index2 () const { return it2_.index2 (); } // Assignment BOOST_UBLAS_INLINE iterator2 &operator = (const iterator2 &it) { container_reference<self_type>::assign (&it ()); it2_ = it.it2_; return *this; } // Comparison BOOST_UBLAS_INLINE bool operator == (const iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ == it.it2_; } BOOST_UBLAS_INLINE bool operator < (const iterator2 &it) const { BOOST_UBLAS_CHECK (&(*this) () == &it (), external_logic ()); return it2_ < it.it2_; } private: subiterator2_type it2_; friend class const_iterator2; };#endif BOOST_UBLAS_INLINE iterator2 begin2 () { return find2 (0, 0, 0); } BOOST_UBLAS_INLINE iterator2 end2 () { return find2 (0, 0, size2 ()); } // Reverse iterators BOOST_UBLAS_INLINE const_reverse_iterator1 rbegin1 () const { return const_reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE const_reverse_iterator1 rend1 () const { return const_reverse_iterator1 (begin1 ()); } BOOST_UBLAS_INLINE reverse_iterator1 rbegin1 () { return reverse_iterator1 (end1 ()); } BOOST_UBLAS_INLINE reverse_iterator1 rend1 () { return reverse_iterator1 (begin1 ()); } BOOST_UBLAS_INLINE const_reverse_iterator2 rbegin2 () const { return const_reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE const_reverse_iterator2 rend2 () const { return const_reverse_iterator2 (begin2 ()); } BOOST_UBLAS_INLINE reverse_iterator2 rbegin2 () { return reverse_iterator2 (end2 ()); } BOOST_UBLAS_INLINE reverse_iterator2 rend2 () { return reverse_iterator2 (begin2
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?