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

📄 _list.h

📁 symbian 上的stl_port进过编译的。
💻 H
📖 第 1 页 / 共 2 页
字号:
  reverse_iterator rbegin()             { return reverse_iterator(end()); }  const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }  reverse_iterator rend()               { return reverse_iterator(begin()); }  const_reverse_iterator rend() const   { return const_reverse_iterator(begin()); }  size_type size() const {    size_type __result = distance(begin(), end());    return __result;  }  size_type max_size() const { return size_type(-1); }  reference front()             { return *begin(); }  const_reference front() const { return *begin(); }  reference back()              { return *(--end()); }  const_reference back() const  { return *(--end()); }private:  void _M_swap_aux(_Self& __x) {    __x._M_node._M_swap_alloc(this->_M_node);    __x._M_node._M_data._M_next = this->_M_node._M_data._M_next;    __x._M_node._M_data._M_next->_M_prev = &__x._M_node._M_data;    __x._M_node._M_data._M_prev = this->_M_node._M_data._M_prev;    __x._M_node._M_data._M_prev->_M_next = &__x._M_node._M_data;    this->_M_empty_initialize();  }public:  void swap(_Self& __x) {    if (__x.empty()) {      if (this->empty()) {        return;      }      this->_M_swap_aux(__x);    } else if (this->empty()) {      __x._M_swap_aux(*this);    } else {      this->_M_node.swap(__x._M_node);      _STLP_STD::swap(this->_M_node._M_data._M_prev->_M_next, __x._M_node._M_data._M_prev->_M_next);      _STLP_STD::swap(this->_M_node._M_data._M_next->_M_prev, __x._M_node._M_data._M_next->_M_prev);    }  }#if !defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)  iterator insert(iterator __pos, const_reference __x = value_type()) {#else  iterator insert(iterator __pos, const_reference __x) {#endif /*!_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/    _Node_base* __tmp = _M_create_node(__x);    _Node_base* __n = __pos._M_node;    _Node_base* __p = __n->_M_prev;    __tmp->_M_next = __n;    __tmp->_M_prev = __p;    __p->_M_next = __tmp;    __n->_M_prev = __tmp;    return iterator(__tmp);  }private:#if defined (_STLP_MEMBER_TEMPLATES)  template <class _InputIterator>  void _M_insert(iterator __pos, _InputIterator __first, _InputIterator __last) {    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;    _M_insert_dispatch(__pos, __first, __last, _Integral());  }  // Check whether it's an integral type.  If so, it's not an iterator.  template<class _Integer>  void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,                          const __true_type& /*_IsIntegral*/) {    _M_fill_insert(__pos, __n, __x);  }  template <class _InputIter>  void _M_insert_dispatch(iterator __pos,                          _InputIter __first, _InputIter __last,                          const __false_type& /*_IsIntegral*/) {#else /* _STLP_MEMBER_TEMPLATES */  void _M_insert(iterator __pos, const value_type* __first, const value_type* __last) {    for (; __first != __last; ++__first)      insert(__pos, *__first);  }  void _M_insert(iterator __pos, const_iterator __first, const_iterator __last) {#endif /* _STLP_MEMBER_TEMPLATES */    //We use a temporary list to avoid the auto reference troubles (infinite loop)    for (; __first != __last; ++__first)      insert(__pos, *__first);  }public:#if defined (_STLP_MEMBER_TEMPLATES)  template <class _InputIterator>  void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;    _M_splice_insert_dispatch(__pos, __first, __last, _Integral());  }private:  // Check whether it's an integral type.  If so, it's not an iterator.  template<class _Integer>  void _M_splice_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,                          const __true_type& /*_IsIntegral*/) {    _M_fill_insert(__pos, __n, __x);  }  template <class _InputIter>  void _M_splice_insert_dispatch(iterator __pos,                          _InputIter __first, _InputIter __last,                          const __false_type& /*_IsIntegral*/) {#else /* _STLP_MEMBER_TEMPLATES */  void insert(iterator __pos, const value_type* __first, const value_type* __last) {    _Self __tmp(__first, __last, this->get_allocator());    splice(__pos, __tmp);  }  void insert(iterator __pos, const_iterator __first, const_iterator __last) {#endif /* _STLP_MEMBER_TEMPLATES */    //We use a temporary list to avoid the auto reference troubles (infinite loop)    _Self __tmp(__first, __last, this->get_allocator());    splice(__pos, __tmp);  }public:  void insert(iterator __pos, size_type __n, const_reference __x)  { _M_fill_insert(__pos, __n, __x); }private:  void _M_fill_insert(iterator __pos, size_type __n, const_reference __x) {    for ( ; __n > 0; --__n)      insert(__pos, __x);  }public:  void push_front(const_reference __x) { insert(begin(), __x); }  void push_back (const_reference __x) { insert(end(), __x); }#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)  iterator insert(iterator __pos)  { return insert(__pos, _STLP_DEFAULT_CONSTRUCTED(value_type)); }  void push_front() {insert(begin());}  void push_back() {insert(end());}# endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/  iterator erase(iterator __pos) {    _Node_base* __next_node = __pos._M_node->_M_next;    _Node_base* __prev_node = __pos._M_node->_M_prev;    _Node* __n = __STATIC_CAST(_Node*, __pos._M_node);    __prev_node->_M_next = __next_node;    __next_node->_M_prev = __prev_node;    _STLP_STD::_Destroy(&__n->_M_data);    this->_M_node.deallocate(__n, 1);    return iterator(__next_node);  }  iterator erase(iterator __first, iterator __last) {    while (__first != __last)      erase(__first++);    return __last;  }#if !defined (_STLP_DONT_SUP_DFLT_PARAM)  void resize(size_type __new_size, const_reference __x = value_type());#else  void resize(size_type __new_size, const_reference __x);  void resize(size_type __new_size)  { this->resize(__new_size, _STLP_DEFAULT_CONSTRUCTED(value_type)); }#endif /*!_STLP_DONT_SUP_DFLT_PARAM*/  void pop_front() { erase(begin()); }  void pop_back() {    iterator __tmp = end();    erase(--__tmp);  }public:  // assign(), a generalized assignment member function.  Two  // versions: one that takes a count, and one that takes a range.  // The range version is a member template, so we dispatch on whether  // or not the type is an integer.  void assign(size_type __n, const_reference __val) { _M_fill_assign(__n, __val); }  void _M_fill_assign(size_type __n, const_reference __val);#if defined (_STLP_MEMBER_TEMPLATES)  template <class _InputIterator>  void assign(_InputIterator __first, _InputIterator __last) {    typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;    _M_assign_dispatch(__first, __last, _Integral());  }  template <class _Integer>  void _M_assign_dispatch(_Integer __n, _Integer __val,                          const __true_type& /*_IsIntegral*/) {    _M_fill_assign(__n, __val);  }  template <class _InputIterator>  void _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,                          const __false_type& /*_IsIntegral*/) {#else  void assign(const value_type *__first2, const value_type *__last2) {    iterator __first1 = begin();    iterator __last1 = end();    for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)      *__first1 = *__first2;    if (__first2 == __last2)      erase(__first1, __last1);    else      insert(__last1, __first2, __last2);  }  void assign(const_iterator __first2, const_iterator __last2) {#endif /* _STLP_MEMBER_TEMPLATES */    iterator __first1 = begin();    iterator __last1 = end();    for ( ; __first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)      *__first1 = *__first2;    if (__first2 == __last2)      erase(__first1, __last1);    else      insert(__last1, __first2, __last2);  }public:  void splice(iterator __pos, _Self& __x) {    if (!__x.empty()) {      if (this->get_allocator() == __x.get_allocator()) {        _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __x.begin()._M_node, __x.end()._M_node);      }      else {        insert(__pos, __x.begin(), __x.end());        __x.clear();      }    }  }  void splice(iterator __pos, _Self& __x, iterator __i) {    iterator __j = __i;    ++__j;    if (__pos == __i || __pos == __j) return;    if (this->get_allocator() == __x.get_allocator()) {      _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __i._M_node, __j._M_node);    }    else {      insert(__pos, *__i);      __x.erase(__i);    }  }  void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {    if (__first != __last) {      if (this->get_allocator() == __x.get_allocator()) {        _STLP_PRIV _List_global_inst::_Transfer(__pos._M_node, __first._M_node, __last._M_node);      }      else {        insert(__pos, __first, __last);        __x.erase(__first, __last);      }    }  }  void remove(const_reference __val) {    iterator __first = begin();    iterator __last = end();    while (__first != __last) {      iterator __next = __first;      ++__next;      if (__val == *__first) erase(__first);      __first = __next;    }  }  void unique()  { _STLP_PRIV _S_unique(*this, equal_to<value_type>()); }  void merge(_Self& __x)  { _STLP_PRIV _S_merge(*this, __x, less<value_type>()); }  void reverse() {    _Node_base* __p = &this->_M_node._M_data;    _Node_base* __tmp = __p;    do {      _STLP_STD::swap(__tmp->_M_next, __tmp->_M_prev);      __tmp = __tmp->_M_prev;     // Old next node is now prev.    } while (__tmp != __p);  }  void sort()  { _STLP_PRIV _S_sort(*this, less<value_type>()); }#if defined (_STLP_MEMBER_TEMPLATES)  template <class _Predicate>  void remove_if(_Predicate __pred)  { _STLP_PRIV _S_remove_if(*this, __pred); }  template <class _BinaryPredicate>  void unique(_BinaryPredicate __binary_pred)  { _STLP_PRIV _S_unique(*this, __binary_pred); }  template <class _StrictWeakOrdering>  void merge(_Self& __x,             _StrictWeakOrdering __comp) {    _STLP_PRIV _S_merge(*this, __x, __comp);  }  template <class _StrictWeakOrdering>  void sort(_StrictWeakOrdering __comp)  { _STLP_PRIV _S_sort(*this, __comp); }#endif /* _STLP_MEMBER_TEMPLATES */};#if defined (list)#  undef list_STLP_MOVE_TO_STD_NAMESPACE#endif_STLP_END_NAMESPACE#if !defined (_STLP_LINK_TIME_INSTANTIATION)#  include <stl/_list.c>#endif#if defined (_STLP_USE_PTR_SPECIALIZATIONS)#  include <stl/pointers/_list.h>#endif#if defined (_STLP_DEBUG)#  include <stl/debug/_list.h>#endif_STLP_BEGIN_NAMESPACEtemplate <class _Tp, class _Alloc>_STLP_INLINE_LOOP bool  _STLP_CALLoperator==(const list<_Tp,_Alloc>& __x, const list<_Tp,_Alloc>& __y) {  typedef typename list<_Tp,_Alloc>::const_iterator const_iterator;  const_iterator __end1 = __x.end();  const_iterator __end2 = __y.end();  const_iterator __i1 = __x.begin();  const_iterator __i2 = __y.begin();  while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {    ++__i1;    ++__i2;  }  return __i1 == __end1 && __i2 == __end2;}#define _STLP_EQUAL_OPERATOR_SPECIALIZED#define _STLP_TEMPLATE_HEADER    template <class _Tp, class _Alloc>#define _STLP_TEMPLATE_CONTAINER list<_Tp, _Alloc>#include <stl/_relops_cont.h>#undef _STLP_TEMPLATE_CONTAINER#undef _STLP_TEMPLATE_HEADER#undef _STLP_EQUAL_OPERATOR_SPECIALIZED#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)template <class _Tp, class _Alloc>struct __move_traits<list<_Tp, _Alloc> > {  typedef __stlp_movable implemented;  typedef typename __move_traits<_Alloc>::complete complete;};#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */_STLP_END_NAMESPACE#endif /* _STLP_INTERNAL_LIST_IMPL_H */// Local Variables:// mode:C++// End:

⌨️ 快捷键说明

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