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

📄 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 页
字号:
        void resize (size_type size, value_type init) {            resize_internal (size, init, true);        }        BOOST_UBLAS_INLINE        void resize (size_type size, pointer data) {            resize_internal (size, data, value_type (), false);        }        BOOST_UBLAS_INLINE        void resize (size_type size, pointer data, value_type init) {            resize_internal (size, data, init, true);        }        BOOST_UBLAS_INLINE        size_type size () const {            return size_;        }        // Element access        BOOST_UBLAS_INLINE        const_reference operator [] (size_type i) const {            BOOST_UBLAS_CHECK (i < size_, bad_index ());            return data_ [i];        }        BOOST_UBLAS_INLINE        reference operator [] (size_type i) {            BOOST_UBLAS_CHECK (i < size_, bad_index ());            return data_ [i];        }        // Assignment        BOOST_UBLAS_INLINE        shallow_array_adaptor &operator = (const shallow_array_adaptor &a) {            if (this != &a) {                resize (a.size_);                std::copy (a.data_.get (), a.data_.get () + a.size_, data_.get ());            }            return *this;        }        BOOST_UBLAS_INLINE        shallow_array_adaptor &assign_temporary (shallow_array_adaptor &a) {            if (own_ && a.own_)                swap (a);            else                *this = a;            return *this;        }        // Swapping        BOOST_UBLAS_INLINE        void swap (shallow_array_adaptor &a) {            if (this != &a) {                std::swap (size_, a.size_);                std::swap (own_, a.own_);                std::swap (data_, a.data_);            }        }#ifndef BOOST_UBLAS_NO_MEMBER_FRIENDS        BOOST_UBLAS_INLINE        friend void swap (shallow_array_adaptor &a1, shallow_array_adaptor &a2) {            a1.swap (a2);        }#endif        // Iterators simply are pointers.        typedef const_pointer const_iterator;        BOOST_UBLAS_INLINE        const_iterator begin () const {            return data_.get ();        }        BOOST_UBLAS_INLINE        const_iterator end () const {            return data_.get () + size_;        }        typedef pointer iterator;        BOOST_UBLAS_INLINE        iterator begin () {            return data_.get ();        }        BOOST_UBLAS_INLINE        iterator end () {            return data_.get () + size_;        }        // Reverse iterators#ifdef BOOST_MSVC_STD_ITERATOR        typedef std::reverse_iterator<const_iterator, value_type, const_reference> const_reverse_iterator;#else        typedef std::reverse_iterator<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 std::reverse_iterator<iterator, value_type, reference> reverse_iterator;#else        typedef std::reverse_iterator<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:        size_type size_;        bool own_;        shared_array<value_type> data_;    };#endif    // Range class    template <class I, class D>    class basic_range {    public:        typedef I size_type;        typedef D difference_type;        typedef size_type value_type;        typedef value_type const_reference;        typedef const_reference reference;        typedef const value_type *const_pointer;        typedef value_type *pointer;    private:        typedef basic_range<I, D> self_type;    public:        // Construction and destruction        BOOST_UBLAS_INLINE        basic_range ():            start_ (0), size_ (0) {}        BOOST_UBLAS_INLINE        basic_range (size_type start, size_type stop):            start_ (start), size_ (stop - start) {            BOOST_UBLAS_CHECK (start_ <= stop, bad_index ());        }        BOOST_UBLAS_INLINE        size_type start () const {            return start_;        }        BOOST_UBLAS_INLINE        size_type size () const {            return size_;        }        // Element access        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            BOOST_UBLAS_CHECK (i < size_, bad_index ());            return start_ + i;        }        // Composition        BOOST_UBLAS_INLINE        basic_range compose (const basic_range &r) const {            return basic_range (start_ + r.start_, start_ + r.start_ + r.size_);        }        // Comparison        BOOST_UBLAS_INLINE        bool operator == (const basic_range &r) const {            return start_ == r.start_ && size_ == r.size_;        }        BOOST_UBLAS_INLINE        bool operator != (const basic_range &r) const {            return ! (*this == r);        }        // Iterator types    private:        // Use and index        typedef size_type const_iterator_type;    public:#ifdef BOOST_UBLAS_USE_INDEXED_ITERATOR        typedef indexed_const_iterator<self_type, std::random_access_iterator_tag> const_iterator;#else        class const_iterator:            public container_const_reference<basic_range>,            public random_access_iterator_base<std::random_access_iterator_tag,                                               const_iterator, value_type> {        public:#ifdef BOOST_MSVC_STD_ITERATOR            typedef const_reference reference;#else            typedef typename basic_range::value_type value_type;            typedef typename basic_range::difference_type difference_type;            typedef typename basic_range::const_reference reference;            typedef typename basic_range::const_pointer pointer;#endif            // Construction and destruction            BOOST_UBLAS_INLINE            const_iterator ():                container_const_reference<basic_range> (), it_ () {}            BOOST_UBLAS_INLINE            const_iterator (const basic_range &r, const const_iterator_type &it):                container_const_reference<basic_range> (r), it_ (it) {}            // Arithmetic            BOOST_UBLAS_INLINE            const_iterator &operator ++ () {                ++ it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator &operator -- () {                BOOST_UBLAS_CHECK (it_ > 0, bad_index ());                -- it_;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator &operator += (difference_type n) {                BOOST_UBLAS_CHECK (n >= 0 || it_ >= size_type(-n), bad_index ());                it_ += n;                return *this;            }            BOOST_UBLAS_INLINE            const_iterator &operator -= (difference_type n) {                BOOST_UBLAS_CHECK (n <= 0 || it_ >= size_type(n), bad_index ());                it_ -= n;                return *this;            }            BOOST_UBLAS_INLINE            difference_type operator - (const const_iterator &it) const {                return it_ - it.it_;            }            // Dereference            BOOST_UBLAS_INLINE            const_reference operator * () const {                BOOST_UBLAS_CHECK ((*this) ().start () <= it_, bad_index ());                BOOST_UBLAS_CHECK (it_ < (*this) ().start () + (*this) ().size (), bad_index ());                return it_;            }            // Index            BOOST_UBLAS_INLINE            size_type index () const {                BOOST_UBLAS_CHECK ((*this) ().start () <= it_, bad_index ());                BOOST_UBLAS_CHECK (it_ < (*this) ().start () + (*this) ().size (), bad_index ());                return it_ - (*this) ().start ();            }            // Assignment            BOOST_UBLAS_INLINE            const_iterator &operator = (const const_iterator &it) {                // Comeau recommends...                this->assign (&it ());                it_ = it.it_;                return *this;            }            // Comparison            BOOST_UBLAS_INLINE            bool operator == (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ());                return it_ == it.it_;            }            BOOST_UBLAS_INLINE            bool operator < (const const_iterator &it) const {                BOOST_UBLAS_CHECK ((*this) () == it (), external_logic ());                return it_ < it.it_;            }        private:            const_iterator_type it_;        };#endif        BOOST_UBLAS_INLINE        const_iterator begin () const {            return const_iterator (*this, start_);        }        BOOST_UBLAS_INLINE        const_iterator end () const {            return const_iterator (*this, start_ + size_);        }        // Reverse iterator#ifdef BOOST_MSVC_STD_ITERATOR        typedef std::reverse_iterator<const_iterator, value_type, const_reference> const_reverse_iterator;#else        typedef std::reverse_iterator<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 ());        }        BOOST_UBLAS_INLINE        basic_range preprocess (size_type size) const {            if (*this != all ())                return *this;            return basic_range (0, size);        }        static        BOOST_UBLAS_INLINE        basic_range all () {            return basic_range (0, size_type (-1));        }    private:        size_type start_;        size_type size_;    };    // Slice class    template <class I, class D>    class basic_slice {    public:        typedef I size_type;        typedef D difference_type;        typedef size_type value_type;        typedef value_type const_reference;        typedef const_reference reference;        typedef const value_type *const_pointer;        typedef value_type *pointer;    private:        typedef basic_slice<I, D> self_type;    public:        // Construction and destruction        BOOST_UBLAS_INLINE        basic_slice ():            start_ (0), stride_ (0), size_ (0) {}        BOOST_UBLAS_INLINE        basic_slice (size_type start, difference_type stride, size_type size):            start_ (start), stride_ (stride), size_ (size) {}        BOOST_UBLAS_INLINE        size_type start () const {            return start_;        }        BOOST_UBLAS_INLINE        difference_type stride () const {            return stride_;        }        BOOST_UBLAS_INLINE        size_type size () const {            return size_;        }        // Element access        BOOST_UBLAS_INLINE        const_reference operator () (size_type i) const {            BOOST_UBLAS_CHECK (i < size_, bad_index ());            BOOST_UBLAS_CHECK (stride_ >= 0 || start_ >= i * -stride_, bad_index ());            return start_ + i * stride_;        }        // Composition        BOOST_UBLAS_INLINE        basic_slice compose (const basic_range<size_type, difference_type> &r) const {            BOOST_UBLAS_CHECK (stride_ >=0 || start_ >= -stride_ * r.start(), bad_index ());            return basic_slice (start_ + stride_ * r.start (), stride_, r.size ());        }        BOOST_UBLAS_INLINE        basic_slice compose (const basic_slice &s) const {            BOOST_UBLAS_CHECK (stride_ >=0 || start_ >= -stride_ * s.start_, bad_index ());            return basic_slice (start_ + stride_ * s.start_, stride_ * s.stride_, s.size_);        }        // Comparison        BOOST_UBLAS_INLINE        bool operator == (const basic_slice &s) const {            return start_ == s.start_ && stride_ == s.stride_ && size_ == s.size_;         }        BOOST_UBLAS_INLINE

⌨️ 快捷键说明

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