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

📄 _vector.h

📁 MONA是为数不多的C++语言编写的一个很小的操作系统
💻 H
📖 第 1 页 / 共 2 页
字号:
# endif    copy(__first, __mid, this->_M_start);    this->_M_finish = __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());    }  }#ifdef _STLP_MEMBER_TEMPLATES  template <class _InputIter>  void _M_assign_aux(_InputIter __first, _InputIter __last,		     const input_iterator_tag &) {    iterator __cur = begin();    for ( ; __first != __last && __cur != end(); ++__cur, ++__first)      *__cur = *__first;    if (__first == __last)      erase(__cur, end());    else      insert(end(), __first, __last);  }    template <class _Integer>  void _M_assign_dispatch(_Integer __n, _Integer __val, const __true_type&)    { assign((size_type) __n, (_Tp) __val); }  template <class _InputIter>  void _M_assign_dispatch(_InputIter __first, _InputIter __last, const __false_type&)    { _M_assign_aux(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIter)); }  template <class _InputIterator>  void assign(_InputIterator __first, _InputIterator __last) {    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;    _M_assign_dispatch(__first, __last, _Integral());  }#endif /* _STLP_MEMBER_TEMPLATES */  void push_back(const _Tp& __x) {    if (this->_M_finish != this->_M_end_of_storage._M_data) {      _Construct(this->_M_finish, __x);      ++this->_M_finish;    }    else      _M_insert_overflow(this->_M_finish, __x, _IsPODType(), 1UL, true);  }  void swap(vector<_Tp, _Alloc>& __x) {    _STLP_STD::swap(this->_M_start, __x._M_start);    _STLP_STD::swap(this->_M_finish, __x._M_finish);    _STLP_STD::swap(this->_M_end_of_storage, __x._M_end_of_storage);  }  iterator insert(iterator __position, const _Tp& __x) {    size_type __n = __position - begin();    if (this->_M_finish != this->_M_end_of_storage._M_data) {      if (__position == end()) {        _Construct(this->_M_finish, __x);        ++this->_M_finish;      } else {        _Construct(this->_M_finish, *(this->_M_finish - 1));        ++this->_M_finish;        _Tp __x_copy = __x;        __copy_backward_ptrs(__position, this->_M_finish - 2, this->_M_finish - 1, _TrivialAss());        *__position = __x_copy;      }    }    else      _M_insert_overflow(__position, __x, _IsPODType(), 1UL);    return begin() + __n;  }# ifndef _STLP_NO_ANACHRONISMS  void push_back() { push_back(_Tp()); }  iterator insert(iterator __position) { return insert(__position, _Tp()); }# endif  void _M_fill_insert (iterator __pos, size_type __n, const _Tp& __x);#if defined ( _STLP_MEMBER_TEMPLATES)  template <class _Integer>  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __val,                          const __true_type&) {    _M_fill_insert(__pos, (size_type) __n, (_Tp) __val);  }  template <class _InputIterator>  void _M_insert_dispatch(iterator __pos,                          _InputIterator __first, _InputIterator __last,                          const __false_type&) {    _M_range_insert(__pos, __first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));  }  // Check whether it's an integral type.  If so, it's not an iterator.  template <class _InputIterator>  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {    typedef typename _Is_integer<_InputIterator>::_Integral _Integral;    _M_insert_dispatch(__pos, __first, __last, _Integral());  }  template <class _InputIterator>  void _M_range_insert(iterator __pos, 		       _InputIterator __first, 		       _InputIterator __last,		       const input_iterator_tag &) {    for ( ; __first != __last; ++__first) {      __pos = insert(__pos, *__first);      ++__pos;    }  }  template <class _ForwardIterator>  void _M_range_insert(iterator __position,                       _ForwardIterator __first,                       _ForwardIterator __last,                       const forward_iterator_tag &) #else /* _STLP_MEMBER_TEMPLATES */  void insert(iterator __position,              const_iterator __first, const_iterator __last)#endif /* _STLP_MEMBER_TEMPLATES */  {    if (__first != __last) {      size_type __n = distance(__first, __last);      if (size_type(this->_M_end_of_storage._M_data - this->_M_finish) >= __n) {        const size_type __elems_after = this->_M_finish - __position;        pointer __old_finish = this->_M_finish;        if (__elems_after > __n) {          __uninitialized_copy(this->_M_finish - __n, this->_M_finish, this->_M_finish, _IsPODType());          this->_M_finish += __n;          __copy_backward_ptrs(__position, __old_finish - __n, __old_finish, _TrivialAss());          copy(__first, __last, __position);        }        else {# if defined ( _STLP_MEMBER_TEMPLATES )          _ForwardIterator __mid = __first;          advance(__mid, __elems_after);# else          const_pointer __mid = __first + __elems_after;# endif          __uninitialized_copy(__mid, __last, this->_M_finish, _IsPODType());          this->_M_finish += __n - __elems_after;          __uninitialized_copy(__position, __old_finish, this->_M_finish, _IsPODType());          this->_M_finish += __elems_after;          copy(__first, __mid, __position);        } /* elems_after */      }      else {        const size_type __old_size = size();        const size_type __len = __old_size + (max)(__old_size, __n);        pointer __new_start = this->_M_end_of_storage.allocate(__len);        pointer __new_finish = __new_start;        _STLP_TRY {          __new_finish = __uninitialized_copy(this->_M_start, __position, __new_start, _IsPODType());          __new_finish = __uninitialized_copy(__first, __last, __new_finish, _IsPODType());          __new_finish = __uninitialized_copy(__position, this->_M_finish, __new_finish, _IsPODType());        }        _STLP_UNWIND((_Destroy(__new_start,__new_finish),                       this->_M_end_of_storage.deallocate(__new_start,__len)));        _M_clear();        _M_set(__new_start, __new_finish, __new_start + __len);      }    }  }  void insert (iterator __pos, size_type __n, const _Tp& __x)  { _M_fill_insert(__pos, __n, __x); }    void pop_back() {    --this->_M_finish;    _Destroy(this->_M_finish);  }  iterator erase(iterator __position) {    if (__position + 1 != end())      __copy_ptrs(__position + 1, this->_M_finish, __position, _TrivialAss());    --this->_M_finish;    _Destroy(this->_M_finish);    return __position;  }  iterator erase(iterator __first, iterator __last) {    pointer __i = __copy_ptrs(__last, this->_M_finish, __first, _TrivialAss());    _Destroy(__i, this->_M_finish);    this->_M_finish = __i;    return __first;  }  void resize(size_type __new_size, _Tp __x) {    if (__new_size < size())       erase(begin() + __new_size, end());    else      insert(end(), __new_size - size(), __x);  }  void resize(size_type __new_size) { resize(__new_size, _Tp()); }  void clear() {     erase(begin(), end());  }protected:  void _M_clear() {    //    if (this->_M_start) {    _Destroy(this->_M_start, this->_M_finish);    this->_M_end_of_storage.deallocate(this->_M_start, this->_M_end_of_storage._M_data - this->_M_start);    //    }  }  void _M_set(pointer __s, pointer __f, pointer __e) {    this->_M_start = __s;    this->_M_finish = __f;    this->_M_end_of_storage._M_data = __e;  }#ifdef _STLP_MEMBER_TEMPLATES  template <class _ForwardIterator>  pointer _M_allocate_and_copy(size_type __n, _ForwardIterator __first, 				_ForwardIterator __last)#else /* _STLP_MEMBER_TEMPLATES */  pointer _M_allocate_and_copy(size_type __n, const_pointer __first, 			       const_pointer __last)#endif /* _STLP_MEMBER_TEMPLATES */  {    pointer __result = this->_M_end_of_storage.allocate(__n);    _STLP_TRY {#if !defined(__MRC__)		//*TY 12/17/2000 - added workaround for MrCpp. it confuses on nested try/catch block      __uninitialized_copy(__first, __last, __result, _IsPODType());#else      uninitialized_copy(__first, __last, __result);#endif      return __result;    }    _STLP_UNWIND(this->_M_end_of_storage.deallocate(__result, __n));# ifdef _STLP_THROW_RETURN_BUG	return __result;# endif  }#ifdef _STLP_MEMBER_TEMPLATES  template <class _InputIterator>  void _M_range_initialize(_InputIterator __first,                             _InputIterator __last, const input_iterator_tag &) {    for ( ; __first != __last; ++__first)      push_back(*__first);  }  // This function is only called by the constructor.   template <class _ForwardIterator>  void _M_range_initialize(_ForwardIterator __first,                           _ForwardIterator __last, const forward_iterator_tag &) {    size_type __n = distance(__first, __last);    this->_M_start = this->_M_end_of_storage.allocate(__n);    this->_M_end_of_storage._M_data = this->_M_start + __n;    this->_M_finish = __uninitialized_copy(__first, __last, this->_M_start, _IsPODType());  }  #endif /* _STLP_MEMBER_TEMPLATES */};# define _STLP_TEMPLATE_CONTAINER vector<_Tp, _Alloc># define _STLP_TEMPLATE_HEADER    template <class _Tp, class _Alloc># include <stl/_relops_cont.h># undef _STLP_TEMPLATE_CONTAINER# undef _STLP_TEMPLATE_HEADER# if defined (_STLP_USE_TEMPLATE_EXPORT) _STLP_EXPORT_TEMPLATE_CLASS allocator<void*>;_STLP_EXPORT_TEMPLATE_CLASS _STLP_alloc_proxy<void**, void*, allocator<void*> >;_STLP_EXPORT_TEMPLATE_CLASS _Vector_base<void*,allocator<void*> >;_STLP_EXPORT_TEMPLATE_CLASS vector<void*,allocator<void*> >;# endif#  undef  vector#  undef  __vector__#  define __vector__ __WORKAROUND_RENAME(vector)_STLP_END_NAMESPACE# if !defined (_STLP_LINK_TIME_INSTANTIATION)#  include <stl/_vector.c># endif#ifndef _STLP_INTERNAL_BVECTOR_H# include <stl/_bvector.h>#endif# if defined (_STLP_DEBUG)#  include <stl/debug/_vector.h># endif# if defined (_STLP_USE_WRAPPER_FOR_ALLOC_PARAM)#  include <stl/wrappers/_vector.h># endif#endif /* _STLP_VECTOR_H */// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

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