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

📄 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 页
字号:
                return *it_;            }            // Index            BOOST_UBLAS_INLINE            size_type index () const {                return it_.index () - (*this) ().start ();            }            // Assignment            BOOST_UBLAS_INLINE            const_iterator &operator = (const const_iterator &it) {                container_const_reference<self_type>::assign (&it ());                it_ = it.it_;                return *this;            }            // Comparison            BOOST_UBLAS_INLINE            bool operator == (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ == it.it_;            }            BOOST_UBLAS_INLINE            bool operator < (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ < it.it_;            }        private:            const_iterator_type it_;        };#endif        BOOST_UBLAS_INLINE        const_iterator begin () const {            return find (0);        }        BOOST_UBLAS_INLINE        const_iterator end () const {            return find (size ());        }#ifndef BOOST_UBLAS_USE_INDEXED_ITERATOR        class iterator:            public container_reference<vector_range>,#ifndef BOOST_UBLAS_NO_ITERATOR_BASE_TRAITS            public iterator_base_traits<typename iterator_type::iterator_category>::template                        iterator_base<iterator, value_type>::type {#else            public random_access_iterator_base<typename V::iterator::iterator_category,                                               iterator, value_type> {#endif        public:            typedef typename iterator_type::iterator_category iterator_category;            typedef typename iterator_type::difference_type difference_type;            typedef typename iterator_type::value_type value_type;            typedef typename iterator_type::reference reference;            typedef typename iterator_type::pointer pointer;            // Construction and destruction            BOOST_UBLAS_INLINE            iterator ():                container_reference<self_type> (), it_ () {}            BOOST_UBLAS_INLINE            iterator (self_type &vr, const iterator_type &it):                container_reference<self_type> (vr), it_ (it) {}            // Arithmetic            BOOST_UBLAS_INLINE            iterator &operator ++ () {                ++ it_;                return *this;            }            BOOST_UBLAS_INLINE            iterator &operator -- () {                -- it_;                return *this;            }            BOOST_UBLAS_INLINE            iterator &operator += (difference_type n) {                it_ += n;                return *this;            }            BOOST_UBLAS_INLINE            iterator &operator -= (difference_type n) {                it_ -= n;                return *this;            }            BOOST_UBLAS_INLINE            difference_type operator - (const iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ - it.it_;            }            // Dereference            BOOST_UBLAS_INLINE            reference operator * () const {                BOOST_UBLAS_CHECK (index () < (*this) ().size (), bad_index ());                return *it_;            }            // Index            BOOST_UBLAS_INLINE            size_type index () const {                return it_.index () - (*this) ().start ();            }            // Assignment            BOOST_UBLAS_INLINE            iterator &operator = (const iterator &it) {                container_reference<self_type>::assign (&it ());                it_ = it.it_;                return *this;            }            // Comparison            BOOST_UBLAS_INLINE            bool operator == (const iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ == it.it_;            }            BOOST_UBLAS_INLINE            bool operator < (const iterator &it) const {                BOOST_UBLAS_CHECK ((*this) ().same_closure (it ()), external_logic ());                return it_ < it.it_;            }        private:            iterator_type it_;            friend class const_iterator;        };#endif        BOOST_UBLAS_INLINE        iterator begin () {            return find (0);        }        BOOST_UBLAS_INLINE        iterator end () {            return find (size ());        }        // Reverse iterator#ifdef BOOST_MSVC_STD_ITERATOR        typedef reverse_iterator_base<const_iterator, value_type, const_reference> const_reverse_iterator;#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 ());        }    private:        vector_closure_type data_;        range_type r_;        static vector_type nil_;    };    template<class V>    typename vector_range<V>::vector_type vector_range<V>::nil_#ifdef BOOST_UBLAS_STATIC_OLD_INIT        = BOOST_UBLAS_TYPENAME vector_range<V>::vector_type ()#endif    ;    // Projections    template<class V>    BOOST_UBLAS_INLINE    vector_range<V> project (V &data, const typename vector_range<V>::range_type &r) {        return vector_range<V> (data, r);    }#ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING    template<class V>    BOOST_UBLAS_INLINE    const vector_range<const V> project_const (const V &data, const typename vector_range<V>::range_type &r) {        return vector_range<const V> (data, r);    }#else    template<class V>    BOOST_UBLAS_INLINE    const vector_range<const V> project (const V &data, const typename vector_range<V>::range_type &r) {        // ISSUE was: return vector_range<V> (const_cast<V &> (data), r);        return vector_range<const V> (data, r);    }    template<class V>    BOOST_UBLAS_INLINE    vector_range<V> project (vector_range<V> &data, const typename vector_range<V>::range_type &r) {        return data.project (r);    }    template<class V>    BOOST_UBLAS_INLINE    const vector_range<V> project (const vector_range<V> &data, const typename vector_range<V>::range_type &r) {        return data.project (r);    }#endif    // Vector based slice class    template<class V>    class vector_slice:        public vector_expression<vector_slice<V> > {    public:#ifndef BOOST_UBLAS_NO_PROXY_SHORTCUTS        BOOST_UBLAS_USING vector_expression<vector_slice<V> >::operator ();#endif        typedef const V const_vector_type;        typedef V vector_type;        typedef typename V::simd_category simd_category;        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_slice<vector_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_slice ():            data_ (nil_), s_ () {}        BOOST_UBLAS_INLINE        vector_slice (vector_type &data, const slice_type &s):            data_ (data), s_ (s.preprocess (data.size ())) {            // Early checking of preconditions here.            // BOOST_UBLAS_CHECK (s_.start () <= data_.size () &&            //                    s_.start () + s_.stride () * (s_.size () - (s_.size () > 0)) <= data_.size (), bad_index ());        }        BOOST_UBLAS_INLINE        vector_slice (const vector_closure_type &data, const slice_type &s, int):            data_ (data), s_ (s.preprocess (data.size ())) {            // Early checking of preconditions here.            // BOOST_UBLAS_CHECK (s_.start () <= data_.size () &&            //                    s_.start () + s_.stride () * (s_.size () - (s_.size () > 0)) <= data_.size (), bad_index ());        }        // Accessors        BOOST_UBLAS_INLINE        size_type start () const {            return s_.start ();        }        BOOST_UBLAS_INLINE        difference_type stride () const {            return s_.stride ();        }        BOOST_UBLAS_INLINE        size_type size () const {            return s_.size ();        }        BOOST_UBLAS_INLINE        const vector_closure_type &data () const {            return data_;        }        BOOST_UBLAS_INLINE        vector_closure_type &data () {            return data_;        }        // Element access#ifndef BOOST_UBLAS_PROXY_CONST_MEMBER        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            return data_ (s_ (i));        }        BOOST_UBLAS_INLINE        reference operator () (size_type i) {            return data_ (s_ (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_ (s_ (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_slice<vector_type> project (const range_type &r) const {            return vector_slice<vector_type>  (data_, s_.compose (r.preprocess (data_.size ())), false);        }        BOOST_UBLAS_INLINE        vector_slice<vector_type> project (const slice_type &s) const {            return vector_slice<vector_type>  (data_, s_.compose (s.preprocess (data_.size ())), false);        }

⌨️ 快捷键说明

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