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

📄 vector_proxy.hpp

📁 CGAL is a collaborative effort of several sites in Europe and Israel. The goal is to make the most i
💻 HPP
📖 第 1 页 / 共 5 页
字号:
#else        typedef reverse_iterator_base<const_iterator> const_reverse_iterator;#endif        BOOST_UBLAS_INLINE        const_reverse_iterator rbegin () const {            return const_reverse_iterator (end ());        }        BOOST_UBLAS_INLINE        const_reverse_iterator rend () const {            return const_reverse_iterator (begin ());        }#ifdef BOOST_MSVC_STD_ITERATOR        typedef reverse_iterator_base<iterator, value_type, reference> reverse_iterator;#else        typedef reverse_iterator_base<iterator> reverse_iterator;#endif        BOOST_UBLAS_INLINE        reverse_iterator rbegin () {            return reverse_iterator (end ());        }        BOOST_UBLAS_INLINE        reverse_iterator rend () {            return reverse_iterator (begin ());        }#ifndef BOOST_UBLAS_NESTED_CLASS_DR45    private:#endif        vector_closure_type data_;        slice_type s_;        static vector_type nil_;    };    template<class V>    typename vector_slice<V>::vector_type vector_slice<V>::nil_#ifdef BOOST_UBLAS_STATIC_OLD_INIT        = BOOST_UBLAS_TYPENAME vector_slice<V>::vector_type ()#endif    ;        // Projections    template<class V>    BOOST_UBLAS_INLINE    vector_slice<V> project (V &data, const typename vector_slice<V>::slice_type &s) {        return vector_slice<V> (data, s);    }#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING    template<class V>    BOOST_UBLAS_INLINE    const vector_slice<const V> project_const (const V &data, const typename vector_slice<V>::slice_type &s) {        return vector_slice<const V> (data, s);    }#else    template<class V>    BOOST_UBLAS_INLINE    const vector_slice<const V> project (const V &data, const typename vector_slice<V>::slice_type &s) {        // ISSUE was: return vector_slice<V> (const_cast<V &> (data), s);        return vector_slice<const V> (data, s);    }    template<class V>    BOOST_UBLAS_INLINE    vector_slice<V> project (vector_slice<V> &data, const typename vector_slice<V>::slice_type &s) {        return data.project (s);    }    template<class V>    BOOST_UBLAS_INLINE    const vector_slice<V> project (const vector_slice<V> &data, const typename vector_slice<V>::slice_type &s) {        return data.project (s);    }#ifndef BOOST_UBLAS_MSVC71_FUNCTION_TEMPLATE_ORDERING    template<class V>    BOOST_UBLAS_INLINE    vector_slice<V> project (vector_slice<V> &data, const typename vector_slice<V>::range_type &r) {        return data.project (r);    }    template<class V>    BOOST_UBLAS_INLINE    const vector_slice<V> project (const vector_slice<V> &data, const typename vector_slice<V>::range_type &r) {        return data.project (r);    }#endif#endif    // Vector based indirection class    // Contributed by Toon Knapen.    // Extended and optimized by Kresimir Fresl.    template<class V, class IA>    class vector_indirect:        public vector_expression<vector_indirect<V, IA> > {    public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING vector_expression<vector_indirect<V, IA> >::operator ();#endif        typedef const V const_vector_type;        typedef V vector_type;        typedef const IA const_indirect_array_type;        typedef IA indirect_array_type;        typedef typename V::size_type size_type;        typedef typename V::difference_type difference_type;        typedef typename V::value_type value_type;#ifndef BOOST_UBLAS_CT_PROXY_BASE_TYPEDEFS        typedef typename V::const_reference const_reference;        typedef typename V::reference reference;#else        typedef typename V::const_reference const_reference;        typedef typename boost::mpl::if_<boost::is_const<V>,                                          typename V::const_reference,                                          typename V::reference>::type reference;#endif#ifndef BOOST_UBLAS_CT_PROXY_CLOSURE_TYPEDEFS        typedef typename V::closure_type vector_closure_type;#else        typedef typename boost::mpl::if_<boost::is_const<V>,                                          typename V::const_closure_type,                                          typename V::closure_type>::type vector_closure_type;#endif    private:        typedef vector_indirect<vector_type, indirect_array_type> self_type;    public:        typedef basic_range<size_type, difference_type> range_type;        typedef basic_slice<size_type, difference_type> slice_type;        typedef const self_type const_closure_type;        typedef self_type closure_type;        typedef typename V::vector_temporary_type vector_temporary_type;        typedef typename storage_restrict_traits<typename V::storage_category,                                                 dense_proxy_tag>::storage_category storage_category;        // Construction and destruction        BOOST_UBLAS_INLINE        vector_indirect ():            data_ (nil_), ia_ () {}        BOOST_UBLAS_INLINE        vector_indirect (vector_type &data, size_type size):            data_ (data), ia_ (size) {}        BOOST_UBLAS_INLINE        vector_indirect (vector_type &data, const indirect_array_type &ia):            data_ (data), ia_ (ia.preprocess (data.size ())) {}        BOOST_UBLAS_INLINE        vector_indirect (const vector_closure_type &data, const indirect_array_type &ia, int):            data_ (data), ia_ (ia.preprocess (data.size ())) {}        // Accessors        BOOST_UBLAS_INLINE        size_type size () const {            return ia_.size ();        }        BOOST_UBLAS_INLINE        const vector_closure_type &data () const {            return data_;        }        BOOST_UBLAS_INLINE        vector_closure_type &data () {            return data_;        }        BOOST_UBLAS_INLINE        const_indirect_array_type &indirect () const {            return ia_;        }        BOOST_UBLAS_INLINE        indirect_array_type &indirect () {            return ia_;        }        // Element access#ifndef BOOST_UBLAS_PROXY_CONST_MEMBER        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            return data_ (ia_ (i));        }        BOOST_UBLAS_INLINE        reference operator () (size_type i) {            return data_ (ia_ (i));        }        BOOST_UBLAS_INLINE        const_reference operator [] (size_type i) const {            return (*this) (i);        }        BOOST_UBLAS_INLINE        reference operator [] (size_type i) {            return (*this) (i);        }#else        BOOST_UBLAS_INLINE        reference operator () (size_type i) const {            return data_ (ia_ (i));        }        BOOST_UBLAS_INLINE        reference operator [] (size_type i) const {            return (*this) (i);        }#endif        // ISSUE can this be done in free project function?        // Although a const function can create a non-const proxy to a non-const object        // Critical is that vector_type and data_ (vector_closure_type) are const correct        BOOST_UBLAS_INLINE        vector_indirect<vector_type, indirect_array_type> project (const range_type &r) const {            return vector_indirect<vector_type, indirect_array_type> (data_, ia_.compose (r.preprocess (data_.size ())), 0);        }        BOOST_UBLAS_INLINE        vector_indirect<vector_type, indirect_array_type> project (const slice_type &s) const {            return vector_indirect<vector_type, indirect_array_type> (data_, ia_.compose (s.preprocess (data_.size ())), 0);        }        BOOST_UBLAS_INLINE        vector_indirect<vector_type, indirect_array_type> project (const indirect_array_type &ia) const {            return vector_indirect<vector_type, indirect_array_type> (data_, ia_.compose (ia.preprocess (data_.size ())), 0);        }        // Assignment        BOOST_UBLAS_INLINE        vector_indirect &operator = (const vector_indirect &vi) {            // FIXME: the indirect_arrays could be differently sized.            // std::copy (vi.begin (), vi.end (), begin ());            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME vector_temporary_type::value_type> (), *this, vector_temporary_type (vi));            return *this;        }        BOOST_UBLAS_INLINE        vector_indirect &assign_temporary (vector_indirect &vi) {            // FIXME: this is suboptimal.            // return *this = vi;            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, value_type> (), *this, vi);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &operator = (const vector_expression<AE> &ae) {            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME vector_temporary_type::value_type> (), *this, vector_temporary_type (ae));            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &assign (const vector_expression<AE> &ae) {            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &operator += (const vector_expression<AE> &ae) {            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME vector_temporary_type::value_type> (), *this, vector_temporary_type (*this + ae));            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &plus_assign (const vector_expression<AE> &ae) {            vector_assign (scalar_plus_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &operator -= (const vector_expression<AE> &ae) {            vector_assign (scalar_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME vector_temporary_type::value_type> (), *this, vector_temporary_type (*this - ae));            return *this;        }        template<class AE>        BOOST_UBLAS_INLINE        vector_indirect &minus_assign (const vector_expression<AE> &ae) {            vector_assign (scalar_minus_assign<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME AE::value_type> (), *this, ae);            return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        vector_indirect &operator *= (const AT &at) {            vector_assign_scalar (scalar_multiplies_assign<BOOST_UBLAS_TYPENAME iterator::reference, AT> (), *this, at);            return *this;        }        template<class AT>        BOOST_UBLAS_INLINE        vector_indirect &operator /= (const AT &at) {            vector_assign_scalar (scalar_divides_assign<BOOST_UBLAS_TYPENAME iterator::reference, AT> (), *this, at);            return *this;        }        // Closure comparison        BOOST_UBLAS_INLINE        bool same_closure (const vector_indirect &vr) const {return true;        }        // Comparison        BOOST_UBLAS_INLINE        bool operator == (const vector_indirect &vi) const {            return (*this).data_ == vi.data_ && ia_ == vi.ia_;        }        // Swapping        BOOST_UBLAS_INLINE        void swap (vector_indirect vi) {            if (this != &vi) {                BOOST_UBLAS_CHECK (size () == vi.size (), bad_size ());                // Sparse ranges may be nonconformant now.                // std::swap_ranges (begin (), end (), vi.begin ());                vector_swap (scalar_swap<BOOST_UBLAS_TYPENAME iterator::reference, BOOST_UBLAS_TYPENAME iterator::reference> (), *this, vi);            }        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend void swap (vector_indirect vi1, vector_indirect vi2) {            vi1.swap (vi2);        }#endif        // Iterator types    private:        // Use indirect array as an index - FIXME this fails for packed assignment        typedef typename IA::const_iterator const_iterator_type;        typedef typename IA::const_iterator iterator_type;    public:#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR        typedef indexed_iterator<vector_indirect<vector_type, indirect_array_type>,                                 BOOST_UBLAS_TYPENAME vector_type::iterator::iterator_category> iterator;        typedef indexed_const_iterator<vector_indirect<vector_type, indirect_array_type>,                                       BOOST_UBLAS_TYPENAME vector_type::const_iterator::iterator_category> const_iterator;#else        class const_iterator;        class iterator;#endif        // Element lookup        BOOST_UBLAS_INLINE        const_iterator find (size_type i) const {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return const_iterator (*this, i);#else            return const_iterator (*this, ia_.begin () + i);#endif        }        BOOST_UBLAS_INLINE        iterator find (size_type i) {#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR            return iterator (*this, i);#else            return iterator (*this, ia_.begin () + i);#endif        }        // Iterators simply are indices.#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class const_iterator:

⌨️ 快捷键说明

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