1.1 --- a/epoc32/include/stdapis/stlport/stl/_list.c Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,252 +0,0 @@
1.4 -/*
1.5 - *
1.6 - *
1.7 - * Copyright (c) 1994
1.8 - * Hewlett-Packard Company
1.9 - *
1.10 - * Copyright (c) 1996,1997
1.11 - * Silicon Graphics Computer Systems, Inc.
1.12 - *
1.13 - * Copyright (c) 1997
1.14 - * Moscow Center for SPARC Technology
1.15 - *
1.16 - * Copyright (c) 1999
1.17 - * Boris Fomitchev
1.18 - *
1.19 - * This material is provided "as is", with absolutely no warranty expressed
1.20 - * or implied. Any use is at your own risk.
1.21 - *
1.22 - * Permission to use or copy this software for any purpose is hereby granted
1.23 - * without fee, provided the above notices are retained on all copies.
1.24 - * Permission to modify the code and to distribute modified code is granted,
1.25 - * provided the above notices are retained, and a notice that the code was
1.26 - * modified is included with the above copyright notice.
1.27 - *
1.28 - */
1.29 -#ifndef _STLP_LIST_C
1.30 -#define _STLP_LIST_C
1.31 -
1.32 -#ifndef _STLP_INTERNAL_LIST_H
1.33 -# include <stl/_list.h>
1.34 -#endif
1.35 -
1.36 -#if defined (__WATCOMC__) || defined (_STLP_USE_TRAP_LEAVE)
1.37 -#include <vector>
1.38 -#endif
1.39 -
1.40 -# undef list
1.41 -# define list __WORKAROUND_DBG_RENAME(list)
1.42 -
1.43 -_STLP_BEGIN_NAMESPACE
1.44 -
1.45 -# if defined (_STLP_EXPOSE_GLOBALS_IMPLEMENTATION)
1.46 -
1.47 -template <class _Dummy>
1.48 -void _STLP_CALL
1.49 -_List_global<_Dummy>::_Transfer(_List_node_base* __position,
1.50 - _List_node_base* __first, _List_node_base* __last) {
1.51 - if (__position != __last) {
1.52 - // Remove [first, last) from its old position.
1.53 - ((_Node*) (__last->_M_prev))->_M_next = __position;
1.54 - ((_Node*) (__first->_M_prev))->_M_next = __last;
1.55 - ((_Node*) (__position->_M_prev))->_M_next = __first;
1.56 -
1.57 - // Splice [first, last) into its new position.
1.58 - _Node* __tmp = (_Node*) (__position->_M_prev);
1.59 - __position->_M_prev = __last->_M_prev;
1.60 - __last->_M_prev = __first->_M_prev;
1.61 - __first->_M_prev = __tmp;
1.62 - }
1.63 -}
1.64 -
1.65 -#endif /* defined (__BUILDING_STLPORT) || ! defined (_STLP_OWN_IOSTREAMS) */
1.66 -
1.67 -
1.68 -template <class _Tp, class _Alloc>
1.69 -void
1.70 -_List_base<_Tp,_Alloc>::clear()
1.71 -{
1.72 - _List_node<_Tp>* __cur = this->_M_node._M_data;
1.73 - if (!__cur)
1.74 - return;
1.75 - __cur = (_List_node<_Tp>*)__cur->_M_next;
1.76 - while (__cur != this->_M_node._M_data) {
1.77 - _List_node<_Tp>* __tmp = __cur;
1.78 - __cur = (_List_node<_Tp>*) __cur->_M_next;
1.79 - _STLP_STD::_Destroy(&__tmp->_M_data);
1.80 - this->_M_node.deallocate(__tmp, 1);
1.81 - }
1.82 - this->_M_node._M_data->_M_next = this->_M_node._M_data;
1.83 - this->_M_node._M_data->_M_prev = this->_M_node._M_data;
1.84 -}
1.85 -
1.86 -# if defined (_STLP_NESTED_TYPE_PARAM_BUG)
1.87 -# define size_type size_t
1.88 -# endif
1.89 -
1.90 -template <class _Tp, class _Alloc>
1.91 -void list<_Tp, _Alloc>::resize(size_type __new_size, _Tp __x)
1.92 -{
1.93 - iterator __i = begin();
1.94 - size_type __len = 0;
1.95 - for ( ; __i != end() && __len < __new_size; ++__i, ++__len);
1.96 -
1.97 - if (__len == __new_size)
1.98 - erase(__i, end());
1.99 - else // __i == end()
1.100 - insert(end(), __new_size - __len, __x);
1.101 -}
1.102 -
1.103 -template <class _Tp, class _Alloc>
1.104 -list<_Tp, _Alloc>& list<_Tp, _Alloc>::operator=(const list<_Tp, _Alloc>& __x)
1.105 -{
1.106 - if (this != &__x) {
1.107 - iterator __first1 = begin();
1.108 - iterator __last1 = end();
1.109 - const_iterator __first2 = __x.begin();
1.110 - const_iterator __last2 = __x.end();
1.111 - while (__first1 != __last1 && __first2 != __last2)
1.112 - *__first1++ = *__first2++;
1.113 - if (__first2 == __last2)
1.114 - erase(__first1, __last1);
1.115 - else
1.116 - insert(__last1, __first2, __last2);
1.117 - }
1.118 - return *this;
1.119 -}
1.120 -
1.121 -template <class _Tp, class _Alloc>
1.122 -void list<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {
1.123 - iterator __i = begin();
1.124 - for ( ; __i != end() && __n > 0; ++__i, --__n)
1.125 - *__i = __val;
1.126 - if (__n > 0)
1.127 - insert(end(), __n, __val);
1.128 - else
1.129 - erase(__i, end());
1.130 -}
1.131 -
1.132 -template <class _Tp, class _Alloc, class _Predicate>
1.133 -void _S_remove_if(list<_Tp, _Alloc>& __that, _Predicate __pred) {
1.134 - typename list<_Tp, _Alloc>::iterator __first = __that.begin();
1.135 - typename list<_Tp, _Alloc>::iterator __last = __that.end();
1.136 - while (__first != __last) {
1.137 - typename list<_Tp, _Alloc>::iterator __next = __first;
1.138 - ++__next;
1.139 - if (__pred(*__first)) __that.erase(__first);
1.140 - __first = __next;
1.141 - }
1.142 -}
1.143 -
1.144 -template <class _Tp, class _Alloc, class _BinaryPredicate>
1.145 -void _S_unique(list<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred) {
1.146 - typename list<_Tp, _Alloc>::iterator __first = __that.begin();
1.147 - typename list<_Tp, _Alloc>::iterator __last = __that.end();
1.148 - if (__first == __last) return;
1.149 - typename list<_Tp, _Alloc>::iterator __next = __first;
1.150 - while (++__next != __last) {
1.151 - if (__binary_pred(*__first, *__next))
1.152 - __that.erase(__next);
1.153 - else
1.154 - __first = __next;
1.155 - __next = __first;
1.156 - }
1.157 -}
1.158 -
1.159 -template <class _Tp, class _Alloc, class _StrictWeakOrdering>
1.160 -void _S_merge(list<_Tp, _Alloc>& __that, list<_Tp, _Alloc>& __x,
1.161 - _StrictWeakOrdering __comp) {
1.162 - typedef typename list<_Tp, _Alloc>::iterator _Literator;
1.163 - _Literator __first1 = __that.begin();
1.164 - _Literator __last1 = __that.end();
1.165 - _Literator __first2 = __x.begin();
1.166 - _Literator __last2 = __x.end();
1.167 - while (__first1 != __last1 && __first2 != __last2)
1.168 - if (__comp(*__first2, *__first1)) {
1.169 - _Literator __next = __first2;
1.170 - _List_global_inst::_Transfer(__first1._M_node, __first2._M_node, (++__next)._M_node);
1.171 - __first2 = __next;
1.172 - }
1.173 - else
1.174 - ++__first1;
1.175 - if (__first2 != __last2) _List_global_inst::_Transfer(__last1._M_node, __first2._M_node, __last2._M_node);
1.176 -}
1.177 -
1.178 -template <class _Tp, class _Alloc, class _StrictWeakOrdering>
1.179 -void _S_sort(list<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp) {
1.180 - // Do nothing if the list has length 0 or 1.
1.181 - if (__that._M_node._M_data->_M_next != __that._M_node._M_data &&
1.182 - (__that._M_node._M_data->_M_next)->_M_next != __that._M_node._M_data) {
1.183 -
1.184 -#if !defined (__WATCOMC__)
1.185 -#ifdef _STLP_USE_TRAP_LEAVE
1.186 - typedef vector<list<_Tp, _Alloc>*, _Alloc> _TmpVec;
1.187 - _TmpVec* __pTmp = new _TmpVec();
1.188 - _TmpVec& __counter = *__pTmp;
1.189 - for (int i = 0; 1< 64; ++i) {
1.190 - list<_Tp, _Alloc>* __pTmp2 = new list<_Tp, _Alloc>;
1.191 - __counter.push_back (__pTmp2);
1.192 - }
1.193 - list<_Tp, _Alloc>* __pcarry = new list<_Tp, _Alloc>;
1.194 - list<_Tp, _Alloc>& __carry = *__pcarry;
1.195 -#else
1.196 - list<_Tp, _Alloc> __counter[64];
1.197 - list<_Tp, _Alloc> __carry;
1.198 -#endif
1.199 -#else
1.200 - list<_Tp, _Alloc> __carry;
1.201 - __vector__<list<_Tp, _Alloc>, _Alloc> __counter(64);
1.202 -#endif
1.203 - int __fill = 0;
1.204 -#ifdef _STLP_USE_TRAP_LEAVE
1.205 - while (!__that.empty()) {
1.206 - __carry.splice(__carry.begin(), __that, __that.begin());
1.207 - int __i = 0;
1.208 -
1.209 - while(__i < __fill && !__counter[__i]->empty()) {
1.210 - _S_merge(*__counter[__i], __carry, __comp);
1.211 - __carry.swap(*__counter[__i++]);
1.212 - }
1.213 - __carry.swap(*__counter[__i]);
1.214 - if (__i == __fill) ++__fill;
1.215 - }
1.216 -
1.217 - for (int __i = 1; __i < __fill; ++__i)
1.218 - _S_merge(*__counter[__i], *__counter[__i-1], __comp);
1.219 - __that.swap(*__counter[__fill-1]);
1.220 -
1.221 - // those objects won't just go away
1.222 - __counter.clear();
1.223 - CleanupStack::Pop(66);
1.224 - }
1.225 -# else
1.226 - while (!__that.empty()) {
1.227 - __carry.splice(__carry.begin(), __that, __that.begin());
1.228 - int __i = 0;
1.229 -
1.230 - while(__i < __fill && !__counter[__i].empty()) {
1.231 - _S_merge(__counter[__i], __carry, __comp);
1.232 - __carry.swap(__counter[__i++]);
1.233 - }
1.234 - __carry.swap(__counter[__i]);
1.235 - if (__i == __fill) ++__fill;
1.236 - }
1.237 -
1.238 - for (int __i = 1; __i < __fill; ++__i)
1.239 - _S_merge(__counter[__i], __counter[__i-1], __comp);
1.240 - __that.swap(__counter[__fill-1]);
1.241 - }
1.242 -# endif
1.243 -
1.244 -}
1.245 -
1.246 -# undef list
1.247 -# undef size_type
1.248 -
1.249 -_STLP_END_NAMESPACE
1.250 -
1.251 -#endif /* _STLP_LIST_C */
1.252 -
1.253 -// Local Variables:
1.254 -// mode:C++
1.255 -// End: