⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iterator.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
////  Copyright (c) 2000-2002//  Joerg Walter, Mathias Koch////  Permission to use, copy, modify, distribute and sell this software//  and its documentation for any purpose is hereby granted without fee,//  provided that the above copyright notice appear in all copies and//  that both that copyright notice and this permission notice appear//  in supporting documentation.  The authors make no representations//  about the suitability of this software for any purpose.//  It is provided "as is" without express or implied warranty.////  The authors gratefully acknowledge the support of//  GeNeSys mbH & Co. KG in producing this work.//#ifndef BOOST_UBLAS_ITERATOR_H#define BOOST_UBLAS_ITERATOR_H#include <iterator>#include <boost/numeric/ublas/exception.hpp>// Using older GCC the following is missing://// namespace std {////    template <class C, class T, class D = std::ptrdiff_t, class P = T *, class R = T &>//    struct iterator {//        typedef C iterator_category;//        typedef T value_type;//        typedef D difference_type;//        typedef P pointer;//        typedef R reference;//    };//// }//// We therefore include the following header#include <boost/iterator.hpp>// and use namespace boost instead of std.namespace boost { namespace numeric { namespace ublas {  /** \brief Base class of all proxy classes that contain   *       a (redirectable) reference to an immutable object.   *   *       \param C the type of the container referred to   */    template<class C>    class container_const_reference:        private nonassignable {    public:        typedef C container_type;        BOOST_UBLAS_INLINE        container_const_reference ():            c_ (0) {}        BOOST_UBLAS_INLINE        container_const_reference (const container_type &c):            c_ (&c) {}        BOOST_UBLAS_INLINE        const container_type &operator () () const {            return *c_;        }        BOOST_UBLAS_INLINE        container_const_reference &assign (const container_type *c) {            c_ = c;            return *this;        }                // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const container_const_reference &cr) const {            return c_ == cr.c_;        }    private:        const container_type *c_;    };  /** \brief Base class of all proxy classes that contain   *         a (redirectable) reference to a mutable object.   *   * \param C the type of the container referred to   */    template<class C>    class container_reference:        private nonassignable {    public:        typedef C container_type;        BOOST_UBLAS_INLINE        container_reference ():            c_ (0) {}        BOOST_UBLAS_INLINE        container_reference (container_type &c):            c_ (&c) {}        BOOST_UBLAS_INLINE        container_type &operator () () const {           return *c_;        }        BOOST_UBLAS_INLINE        container_reference &assign (container_type *c) {            c_ = c;            return *this;        }        // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const container_reference &cr) const {            return c_ == cr.c_;        }    private:        container_type *c_;    };  /** \brief Base class of all forward iterators.   *    *  \param IC the iterator category   *  \param I the derived iterator type   *  \param T the value type   *    * The forward iterator can only proceed in one direction   * via the post increment operator.   */    template<class IC, class I, class T>    struct forward_iterator_base:        public boost::iterator<IC, T> {        typedef I derived_iterator_type;        typedef T derived_value_type;        // Arithmetic        BOOST_UBLAS_INLINE        derived_iterator_type operator ++ (int) {            derived_iterator_type &d (*static_cast<const derived_iterator_type *> (this));            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator ++ (derived_iterator_type &d, int) {            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#endif        // Comparison        BOOST_UBLAS_INLINE        bool operator != (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return ! (*d == it);        }    };#ifdef BOOST_UBLAS_NO_MEMBER_FRIENDS    template<class IC, class I, class T>    BOOST_UBLAS_INLINE    typename forward_iterator_base<IC, I, T>::derived_iterator_type operator ++ (forward_iterator_base<IC, I, T> &it, int) {        typedef BOOST_UBLAS_TYPENAME forward_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;    }#endif  /** \brief Base class of all bidirectional iterators.   *   * \param IC the iterator category   * \param I the derived iterator type   * \param T the value type   *   * The bidirectional iterator can proceed in both directions   * via the post increment and post decrement operator.   */    template<class IC, class I, class T>    struct bidirectional_iterator_base:        public boost::iterator<IC, T> {        typedef I derived_iterator_type;        typedef T derived_value_type;        // Arithmetic        BOOST_UBLAS_INLINE        derived_iterator_type operator ++ (int) {            derived_iterator_type &d (*static_cast<const derived_iterator_type *> (this));            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator ++ (derived_iterator_type &d, int) {            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#endif        BOOST_UBLAS_INLINE        derived_iterator_type operator -- (int) {            derived_iterator_type &d (*static_cast<const derived_iterator_type *> (this));            derived_iterator_type tmp (d);            -- d;            return tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator -- (derived_iterator_type &d, int) {            derived_iterator_type tmp (d);            -- d;            return tmp;        }#endif        // Comparison        BOOST_UBLAS_INLINE        bool operator != (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return ! (*d == it);        }    };#ifdef BOOST_UBLAS_NO_MEMBER_FRIENDS    template<class IC, class I, class T>    BOOST_UBLAS_INLINE    typename bidirectional_iterator_base<IC, I, T>::derived_iterator_type operator ++ (bidirectional_iterator_base<IC, I, T> &it, int) {        typedef BOOST_UBLAS_TYPENAME bidirectional_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 bidirectional_iterator_base<IC, I, T>::derived_iterator_type operator -- (bidirectional_iterator_base<IC, I, T> &it, int) {        typedef BOOST_UBLAS_TYPENAME bidirectional_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;    }#endif  /** \brief Base class of all random access iterators.   *   * \param IC the iterator category   * \param I the derived iterator type   * \param T the value type   * \param D the difference type, default: std::ptrdiff_t   *   * The random access iterator can proceed in both directions   * via the post increment/decrement operator or in larger steps   * via the +, - and +=, -= operators. The random access iterator   * is LessThan Comparable.   */    template<class IC, class I, class T, class D = std::ptrdiff_t>    // ISSUE the default here seems rather dangerous as it can easlly be (silently) incorrect    struct random_access_iterator_base:        public boost::iterator<IC, T> {        typedef I derived_iterator_type;        typedef T derived_value_type;        typedef D derived_difference_type;#ifdef BOOST_MSVC_STD_ITERATOR        typedef D difference_type;#endif        /*         *  FIXME Need to explicitly pass derived_refernce_type as otherwise I undefined type or foward declared        typedef BOOST_UBLAS_TYPENAME derived_iterator_type::reference derived_reference_type;        // Indexed element        BOOST_UBLAS_INLINE        derived_reference_type operator [] (derived_difference_type n) {            return *(*this + n);        }        */        // Arithmetic        BOOST_UBLAS_INLINE        derived_iterator_type operator ++ (int) {            derived_iterator_type &d (*static_cast<derived_iterator_type *> (this));            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator ++ (derived_iterator_type &d, int) {            derived_iterator_type tmp (d);            ++ d;            return tmp;        }#endif        BOOST_UBLAS_INLINE        derived_iterator_type operator -- (int) {            derived_iterator_type &d (*static_cast<derived_iterator_type *> (this));            derived_iterator_type tmp (d);            -- d;            return tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator -- (derived_iterator_type &d, int) {            derived_iterator_type tmp (d);            -- d;            return tmp;        }#endif        BOOST_UBLAS_INLINE        derived_iterator_type operator + (derived_difference_type n) const {            derived_iterator_type tmp (*static_cast<const derived_iterator_type *> (this));            return tmp += n;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator + (const derived_iterator_type &d, derived_difference_type n) {            derived_iterator_type tmp (d);            return tmp += n;        }        BOOST_UBLAS_INLINE        friend derived_iterator_type operator + (derived_difference_type n, const derived_iterator_type &d) {            derived_iterator_type tmp (d);            return tmp += n;        }#endif        BOOST_UBLAS_INLINE        derived_iterator_type operator - (derived_difference_type n) const {            derived_iterator_type tmp (*static_cast<const derived_iterator_type *> (this));            return tmp -= n;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend derived_iterator_type operator - (const derived_iterator_type &d, derived_difference_type n) {            derived_iterator_type tmp (d);            return tmp -= n;        }#endif        // Comparison        BOOST_UBLAS_INLINE        bool operator != (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return ! (*d == it);        }        BOOST_UBLAS_INLINE        bool operator <= (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return ! (it < *d);        }        BOOST_UBLAS_INLINE        bool operator >= (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return ! (*d < it);        }        BOOST_UBLAS_INLINE        bool operator > (const derived_iterator_type &it) const {            const derived_iterator_type *d = static_cast<const derived_iterator_type *> (this);            return it < *d;        }    };#ifdef BOOST_UBLAS_NO_MEMBER_FRIENDS    template<class IC, class I, class T>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -