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

📄 storage.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
        const indirect_array &all () {            return all_;        }    private:        size_type size_;        array_type data_;        static const indirect_array all_;    };    template<class A>    const indirect_array<A> indirect_array<A>::all_;    // Gunter Winkler contributed the classes index_pair, index_pair_array,    // index_triple and index_triple_array to enable inplace sort of parallel arrays.    template <class V>    class index_pair :        private boost::noncopyable,        public container_reference<V> {    public:        typedef index_pair<V> self_type;        typedef typename V::size_type size_type;        BOOST_UBLAS_INLINE        index_pair(V& v, size_type i) :            container_reference<V>(v), i_(i),            v1_(v.data1_[i]), v2_(v.data2_[i]), dirty_(false) {}        BOOST_UBLAS_INLINE        index_pair(const self_type& rhs) :            container_reference<V>(rhs()), i_(rhs.i_),            v1_(rhs.v1_), v2_(rhs.v2_), dirty_(false) {}        BOOST_UBLAS_INLINE        ~index_pair() {            if (dirty_) {                (*this)().data1_[i_] = v1_;                (*this)().data2_[i_] = v2_;            }        }        BOOST_UBLAS_INLINE        self_type& operator=(const self_type& rhs) {            v1_ = rhs.v1_;            v2_ = rhs.v2_;            dirty_ = true;            return *this;        }        BOOST_UBLAS_INLINE        void swap(self_type rhs) {            self_type tmp(rhs);            rhs = *this;            *this = tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend void swap(self_type lhs, self_type rhs) {            lhs.swap(rhs);        }#endif        BOOST_UBLAS_INLINE        bool equal(const self_type& rhs) const {            return (v1_ == rhs.v1_);        }        bool less(const self_type& rhs) const {            return (v1_ < rhs.v1_);        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend bool operator == (const self_type& lhs, const self_type& rhs) {            return lhs.equal(rhs);        }        BOOST_UBLAS_INLINE        friend bool operator != (const self_type& lhs, const self_type& rhs) {            return !lhs.equal(rhs);        }        BOOST_UBLAS_INLINE        friend bool operator < (const self_type& lhs, const self_type& rhs) {            return lhs.less(rhs);        }#endif    private:        size_type i_;        typename V::value1_type v1_;        typename V::value2_type v2_;        bool dirty_;    };#ifdef BOOST_UBLAS_NO_MEMBER_FRIENDS    template<class V>    BOOST_UBLAS_INLINE    void swap(index_pair<V> lhs, index_pair<V> rhs) {        lhs.swap(rhs);    }    template<class V>    BOOST_UBLAS_INLINE    bool operator == (const index_pair<V>& lhs, const index_pair<V>& rhs) {        return lhs.equal(rhs);    }    template<class V>    BOOST_UBLAS_INLINE    bool operator != (const index_pair<V>& lhs, const index_pair<V>& rhs) {        return !lhs.equal(rhs);    }    template<class V>    BOOST_UBLAS_INLINE    bool operator < (const index_pair<V>& lhs, const index_pair<V>& rhs) {        return lhs.less(rhs);    }#endif    template <class V1, class V2>    class index_pair_array:        private boost::noncopyable {    public:        typedef index_pair_array<V1, V2> self_type;        typedef typename V1::value_type value1_type;        typedef typename V2::value_type value2_type;        typedef typename V1::size_type size_type;        typedef typename V1::difference_type difference_type;        typedef index_pair<self_type> value_type;        // There is nothing that can be referenced directly. Always return a copy of the index_pair        typedef value_type reference;        typedef const value_type const_reference;        BOOST_UBLAS_INLINE        index_pair_array(size_type size, V1& data1, V2& data2) :              size_(size),data1_(data1),data2_(data2) {}        BOOST_UBLAS_INLINE        size_type size() const {            return size_;        }        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            return value_type((*this), i);        }        BOOST_UBLAS_INLINE        reference operator () (size_type i) {            return value_type((*this), i);        }        typedef indexed_iterator<self_type, std::random_access_iterator_tag> iterator;        typedef indexed_const_iterator<self_type, std::random_access_iterator_tag> const_iterator;        BOOST_UBLAS_INLINE        iterator begin() {            return iterator( (*this), 0);        }        BOOST_UBLAS_INLINE        iterator end() {            return iterator( (*this), size());        }        BOOST_UBLAS_INLINE        const_iterator begin() const {            return const_iterator( (*this), 0);        }        BOOST_UBLAS_INLINE        const_iterator end() const {            return const_iterator( (*this), size());        }        // unnecessary function:        BOOST_UBLAS_INLINE        bool equal(size_type i1, size_type i2) const {            return data1_[i1] == data1_[i2];        }        BOOST_UBLAS_INLINE        bool less(size_type i1, size_type i2) const {            return data1_[i1] < data1_[i2];        }        // gives a large speedup        BOOST_UBLAS_INLINE        friend void iter_swap(const iterator& lhs, const iterator& rhs) {            const size_type i1 = lhs.index();            const size_type i2 = rhs.index();            std::swap(lhs().data1_[i1], rhs().data1_[i2]);            std::swap(lhs().data2_[i1], rhs().data2_[i2]);        }    private:        size_type size_;        V1& data1_;        V2& data2_;        // friend class value_type;        friend class index_pair<self_type>;    };    template <class M>    class index_triple :        private boost::noncopyable,        public container_reference<M> {    public:        typedef index_triple<M> self_type;        typedef typename M::size_type size_type;        BOOST_UBLAS_INLINE        index_triple(M& m, size_type i) :            container_reference<M>(m), i_(i),            v1_(m.data1_[i]), v2_(m.data2_[i]), v3_(m.data3_[i]), dirty_(false) {}        BOOST_UBLAS_INLINE        index_triple(const self_type& rhs) :            container_reference<M>(rhs()), i_(rhs.i_),            v1_(rhs.v1_), v2_(rhs.v2_), v3_(rhs.v3_), dirty_(false) {}        BOOST_UBLAS_INLINE        ~index_triple() {            if (dirty_) {                (*this)().data1_[i_] = v1_;                (*this)().data2_[i_] = v2_;                (*this)().data3_[i_] = v3_;            }        }        BOOST_UBLAS_INLINE        self_type& operator=(const self_type& rhs) {            v1_ = rhs.v1_;            v2_ = rhs.v2_;            v3_ = rhs.v3_;            dirty_ = true;            return *this;        }        BOOST_UBLAS_INLINE        void swap(self_type rhs) {            self_type tmp(rhs);            rhs = *this;            *this = tmp;        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend void swap(self_type lhs, self_type rhs) {            lhs.swap(rhs);        }#endif        BOOST_UBLAS_INLINE        bool equal(const self_type& rhs) const {            return ((v1_ == rhs.v1_) && (v2_ == rhs.v2_));        }        BOOST_UBLAS_INLINE        bool less(const self_type& rhs) const {            return ((v1_ < rhs.v1_) ||                    (v1_ == rhs.v1_ && v2_ < rhs.v2_));        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend bool operator == (const self_type& lhs, const self_type& rhs) {            return lhs.equal(rhs);        }        BOOST_UBLAS_INLINE        friend bool operator != (const self_type& lhs, const self_type& rhs) {            return !lhs.equal(rhs);        }        BOOST_UBLAS_INLINE        friend bool operator < (const self_type& lhs, const self_type& rhs) {            return lhs.less(rhs);        }#endif    private:        size_type i_;        typename M::value1_type v1_;        typename M::value2_type v2_;        typename M::value3_type v3_;        bool dirty_;    };#ifdef BOOST_UBLAS_NO_MEMBER_FRIENDS    template<class M>    BOOST_UBLAS_INLINE    void swap(index_triple<M> lhs, index_triple<M> rhs) {        lhs.swap(rhs);    }    template<class M>    BOOST_UBLAS_INLINE    bool operator == (const index_triple<M>& lhs, const index_triple<M>& rhs) {        return lhs.equal(rhs);    }    template<class M>    BOOST_UBLAS_INLINE    bool operator != (const index_triple<M>& lhs, const index_triple<M>& rhs) {        return !lhs.equal(rhs);    }    template<class M>    BOOST_UBLAS_INLINE    bool operator < (const index_triple<M>& lhs, const index_triple<M>& rhs) {        return lhs.less(rhs);    }#endif    template <class V1, class V2, class V3>    class index_triple_array:        private boost::noncopyable {    public:        typedef index_triple_array<V1, V2, V3> self_type;        typedef typename V1::value_type value1_type;        typedef typename V2::value_type value2_type;        typedef typename V3::value_type value3_type;        typedef typename V1::size_type size_type;        typedef typename V1::difference_type difference_type;        typedef index_triple<self_type> value_type;        // There is nothing that can be referenced directly. Always return a copy of the index_triple        typedef value_type reference;        typedef const value_type const_reference;        BOOST_UBLAS_INLINE        index_triple_array(size_type size, V1& data1, V2& data2, V3& data3) :              size_(size),data1_(data1),data2_(data2),data3_(data3) {}        BOOST_UBLAS_INLINE        size_type size() const {            return size_;        }        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            return value_type((*this), i);        }        BOOST_UBLAS_INLINE        reference operator () (size_type i) {            return value_type((*this), i);        }        typedef indexed_iterator<self_type, std::random_access_iterator_tag> iterator;        typedef indexed_const_iterator<self_type, std::random_access_iterator_tag> const_iterator;        BOOST_UBLAS_INLINE        iterator begin() {            return iterator( (*this), 0);        }        BOOST_UBLAS_INLINE        iterator end() {            return iterator( (*this), size());        }        BOOST_UBLAS_INLINE        const_iterator begin() const {            return const_iterator( (*this), 0);        }        BOOST_UBLAS_INLINE        const_iterator end() const {            return const_iterator( (*this), size());        }        // unnecessary function:        BOOST_UBLAS_INLINE        bool equal(size_type i1, size_type i2) const {            return ((data1_[i1] == data1_[i2]) && (data2_[i1] == data2_[i2]));        }        BOOST_UBLAS_INLINE        bool less(size_type i1, size_type i2) const {            return ((data1_[i1] < data1_[i2]) ||                    (data1_[i1] == data1_[i2] && data2_[i1] < data2_[i2]));        }        // gives a large speedup        BOOST_UBLAS_INLINE        friend void iter_swap(const iterator& lhs, const iterator& rhs) {            const size_type i1 = lhs.index();            const size_type i2 = rhs.index();            std::swap(lhs().data1_[i1], rhs().data1_[i2]);            std::swap(lhs().data2_[i1], rhs().data2_[i2]);            std::swap(lhs().data3_[i1], rhs().data3_[i2]);        }    private:        size_type size_;        V1& data1_;        V2& data2_;        V3& data3_;        // friend class value_type;        friend class index_triple<self_type>;    };}}}#endif

⌨️ 快捷键说明

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