📄 iterator.hpp
字号:
BOOST_UBLAS_INLINE typename random_access_iterator_base<IC, I, T>::derived_iterator_type operator ++ (random_access_iterator_base<IC, I, T> &it, int) { typedef BOOST_UBLAS_TYPENAME random_access_iterator_base<IC, I, T>::derived_iterator_type derived_iterator_type; derived_iterator_type &d (static_cast<derived_iterator_type &> (it)); derived_iterator_type tmp (d); ++ d; return tmp; } template<class IC, class I, class T> BOOST_UBLAS_INLINE typename random_access_iterator_base<IC, I, T>::derived_iterator_type operator -- (random_access_iterator_base<IC, I, T> &it, int) { typedef BOOST_UBLAS_TYPENAME random_access_iterator_base<IC, I, T>::derived_iterator_type derived_iterator_type; derived_iterator_type &d (static_cast<derived_iterator_type &> (it)); derived_iterator_type tmp (d); -- d; return tmp; } template<class IC, class I, class T> BOOST_UBLAS_INLINE typename random_access_iterator_base<IC, I, T>::derived_iterator_type operator + (const random_access_iterator_base<IC, I, T> &it, std::ptrdiff_t n) { typedef BOOST_UBLAS_TYPENAME random_access_iterator_base<IC, I, T>::derived_iterator_type derived_iterator_type; derived_iterator_type tmp (static_cast<const derived_iterator_type &> (it)); return tmp += n; } template<class IC, class I, class T> BOOST_UBLAS_INLINE typename random_access_iterator_base<IC, I, T>::derived_iterator_type operator + (std::ptrdiff_t n, const random_access_iterator_base<IC, I, T> &it) { typedef BOOST_UBLAS_TYPENAME random_access_iterator_base<IC, I, T>::derived_iterator_type derived_iterator_type; derived_iterator_type tmp (static_cast<const derived_iterator_type &> (it)); return tmp += n; } template<class IC, class I, class T> BOOST_UBLAS_INLINE typename random_access_iterator_base<IC, I, T>::derived_iterator_type operator - (const random_access_iterator_base<IC, I, T> &it, std::ptrdiff_t n) { typedef BOOST_UBLAS_TYPENAME random_access_iterator_base<IC, I, T>::derived_iterator_type derived_iterator_type; derived_iterator_type tmp (static_cast<const derived_iterator_type &> (it)); return tmp -= n; }#endif#ifdef BOOST_MSVC_STD_ITERATOR /** \brief Base class of all reverse iterators. (MSVC version) * * \param I the derived iterator type * \param T the value type * \param R the reference type * * The reverse iterator implements a bidirectional iterator * reversing the elements of the underlying iterator. It * implements most operators of a random access iterator. * * uBLAS extension: it.index() */ // Renamed this class from reverse_iterator to get // typedef reverse_iterator<...> reverse_iterator // working. Thanks to Gabriel Dos Reis for explaining this. template <class I, class T, class R> class reverse_iterator_base: public std::reverse_bidirectional_iterator<I, T, R> { public: typedef typename I::container_type container_type; typedef typename container_type::size_type size_type; typedef typename I::difference_type difference_type; typedef I iterator_type; typedef T value_type; typedef R reference; // Construction and destruction BOOST_UBLAS_INLINE reverse_iterator_base (): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> () {} BOOST_UBLAS_INLINE reverse_iterator_base (const iterator_type &it): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> (it) {} // Arithmetic BOOST_UBLAS_INLINE reverse_iterator_base &operator += (difference_type n) { // Comeau recommends... return *this = this->base () - n; } BOOST_UBLAS_INLINE reverse_iterator_base &operator -= (difference_type n) { // Comeau recommends... return *this = this->base () + n; } BOOST_UBLAS_INLINE const container_type &operator () () const { // Comeau recommends... return this->base () (); } BOOST_UBLAS_INLINE size_type index () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).index (); } // Comparison BOOST_UBLAS_INLINE bool operator < (const reverse_iterator_base &it) const { return ! (this->base () < it.base ()); } BOOST_UBLAS_INLINE bool operator <= (const reverse_iterator_base &it) const { return ! (this->base () <= it.base ()); } BOOST_UBLAS_INLINE bool operator >= (const reverse_iterator_base &it) const { return ! (this->base () >= it.base ()); } BOOST_UBLAS_INLINE bool operator > (const reverse_iterator_base &it) const { return ! (this->base () > it.base ()); } }; template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base<I, T, R> operator + (const reverse_iterator_base<I, T, R> &it, std::ptrdiff_t n) { reverse_iterator_base<I, T, R> tmp (it); return tmp += n; } template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base<I, T, R> operator + (std::ptrdiff_t n, const reverse_iterator_base<I, T, R> &it) { reverse_iterator_base<I, T, R> tmp (it); return tmp += n; } template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base<I, T, R> operator - (const reverse_iterator_base<I, T, R> &it, std::ptrdiff_t n) { reverse_iterator_base<I, T, R> tmp (it); return tmp -= n; } template<class I, class T, class R> BOOST_UBLAS_INLINE std::ptrdiff_t operator - (const reverse_iterator_base<I, T, R> &it1, const reverse_iterator_base<I, T, R> &it2) { return it2.base () - it1.base (); } /** \brief 1st base class of all matrix reverse iterators. (MSVC version) * * \param I the derived iterator type * \param T the value type * \param R the reference type * * The reverse iterator implements a bidirectional iterator * reversing the elements of the underlying iterator. It * implements most operators of a random access iterator. * * uBLAS extension: it.index1(), it.index2() and access to * the dual iterator via begin(), end(), rbegin(), rend() */ // Renamed this class from reverse_iterator1 to get // typedef reverse_iterator1<...> reverse_iterator1 // working. Thanks to Gabriel Dos Reis for explaining this. template <class I, class T, class R> class reverse_iterator_base1: public std::reverse_bidirectional_iterator<I, T, R> { public: typedef typename I::container_type container_type; typedef typename container_type::size_type size_type; typedef typename I::difference_type difference_type; typedef I iterator_type; typedef T value_type; typedef R reference; typedef typename I::dual_iterator_type dual_iterator_type; typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE reverse_iterator_base1 (): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> () {} BOOST_UBLAS_INLINE reverse_iterator_base1 (const iterator_type &it): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> (it) {} // Arithmetic BOOST_UBLAS_INLINE reverse_iterator_base1 &operator += (difference_type n) { // Comeau recommends... return *this = this->base () - n; } BOOST_UBLAS_INLINE reverse_iterator_base1 &operator -= (difference_type n) { // Comeau recommends... return *this = this->base () + n; } BOOST_UBLAS_INLINE const container_type &operator () () const { // Comeau recommends... return this->base () (); } BOOST_UBLAS_INLINE size_type index1 () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).index1 (); } BOOST_UBLAS_INLINE size_type index2 () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).index2 (); } BOOST_UBLAS_INLINE dual_iterator_type begin () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).begin (); } BOOST_UBLAS_INLINE dual_iterator_type end () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).end (); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { return dual_reverse_iterator_type (end ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rend () const { return dual_reverse_iterator_type (begin ()); } // Comparison BOOST_UBLAS_INLINE bool operator < (const reverse_iterator_base1 &it) const { return ! (this->base () < it.base ()); } BOOST_UBLAS_INLINE bool operator <= (const reverse_iterator_base1 &it) const { return ! (this->base () <= it.base ()); } BOOST_UBLAS_INLINE bool operator >= (const reverse_iterator_base1 &it) const { return ! (this->base () >= it.base ()); } BOOST_UBLAS_INLINE bool operator > (const reverse_iterator_base1 &it) const { return ! (this->base () > it.base ()); } }; template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base1<I, T, R> operator + (const reverse_iterator_base1<I, T, R> &it, std::ptrdiff_t n) { reverse_iterator_base1<I, T, R> tmp (it); return tmp += n; } template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base1<I, T, R> operator + (std::ptrdiff_t n, const reverse_iterator_base1<I, T, R> &it) { reverse_iterator_base1<I, T, R> tmp (it); return tmp += n; } template<class I, class T, class R> BOOST_UBLAS_INLINE reverse_iterator_base1<I, T, R> operator - (const reverse_iterator_base1<I, T, R> &it, std::ptrdiff_t n) { reverse_iterator_base1<I, T, R> tmp (it); return tmp -= n; } template<class I, class T, class R> BOOST_UBLAS_INLINE std::ptrdiff_t operator - (const reverse_iterator_base1<I, T, R> &it1, const reverse_iterator_base1<I, T, R> &it2) { return it2.base () - it1.base (); } /** \brief 2nd base class of all matrix reverse iterators. (MSVC version) * * \param I the derived iterator type * \param T the value type * \param R the reference type * * The reverse iterator implements a bidirectional iterator * reversing the elements of the underlying iterator. It * implements most operators of a random access iterator. * * uBLAS extension: it.index1(), it.index2() and access to * the dual iterator via begin(), end(), rbegin(), rend() * * Note: This class is _identical_ to reverse_iterator_base1 */ // Renamed this class from reverse_iterator2 to get // typedef reverse_iterator2<...> reverse_iterator2 // working. Thanks to Gabriel Dos Reis for explaining this. template <class I, class T, class R> class reverse_iterator_base2: public std::reverse_bidirectional_iterator<I, T, R> { public: typedef typename I::container_type container_type; typedef typename container_type::size_type size_type; typedef typename I::difference_type difference_type; typedef I iterator_type; typedef T value_type; typedef R reference; typedef typename I::dual_iterator_type dual_iterator_type; typedef typename I::dual_reverse_iterator_type dual_reverse_iterator_type; // Construction and destruction BOOST_UBLAS_INLINE reverse_iterator_base2 (): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> () {} BOOST_UBLAS_INLINE reverse_iterator_base2 (const iterator_type &it): std::reverse_bidirectional_iterator<iterator_type, value_type, reference> (it) {} // Arithmetic BOOST_UBLAS_INLINE reverse_iterator_base2 &operator += (difference_type n) { // Comeau recommends... return *this = this->base () - n; } BOOST_UBLAS_INLINE reverse_iterator_base2 &operator -= (difference_type n) { // Comeau recommends... return *this = this->base () + n; } BOOST_UBLAS_INLINE const container_type &operator () () const { // Comeau recommends... return this->base () (); } BOOST_UBLAS_INLINE size_type index1 () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).index1 (); } BOOST_UBLAS_INLINE size_type index2 () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).index2 (); } BOOST_UBLAS_INLINE dual_iterator_type begin () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).begin (); } BOOST_UBLAS_INLINE dual_iterator_type end () const { // Comeau recommends... iterator_type tmp (this->base ()); return (-- tmp).end (); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rbegin () const { return dual_reverse_iterator_type (end ()); } BOOST_UBLAS_INLINE dual_reverse_iterator_type rend () const { return dual_reverse_iterator_type (begin ()); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -