ReactOS 0.4.15-dev-8219-ge8b88cf
_list.c File Reference
#include <stl/_list.h>
#include <stl/_carray.h>
#include <stl/_range_errors.h>
Include dependency graph for _list.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define _STLP_LIST_C
 

Functions

template<class _Tp , class _Alloc , class _Predicate >
_STLP_MOVE_TO_PRIV_NAMESPACE void _S_remove_if (list< _Tp, _Alloc > &__that, _Predicate __pred)
 
template<class _Tp , class _Alloc , class _BinaryPredicate >
void _S_unique (list< _Tp, _Alloc > &__that, _BinaryPredicate __binary_pred)
 
template<class _Tp , class _Alloc , class _StrictWeakOrdering >
void _S_merge (list< _Tp, _Alloc > &__that, list< _Tp, _Alloc > &__x, _StrictWeakOrdering __comp)
 
template<class _Tp , class _Alloc , class _StrictWeakOrdering >
void _S_sort (list< _Tp, _Alloc > &__that, _StrictWeakOrdering __comp)
 

Macro Definition Documentation

◆ _STLP_LIST_C

#define _STLP_LIST_C

Definition at line 27 of file _list.c.

Function Documentation

◆ _S_merge()

template<class _Tp , class _Alloc , class _StrictWeakOrdering >
void _S_merge ( list< _Tp, _Alloc > &  __that,
list< _Tp, _Alloc > &  __x,
_StrictWeakOrdering  __comp 
)

Definition at line 168 of file _list.c.

169 {
170 typedef typename list<_Tp, _Alloc>::iterator _Literator;
171 _Literator __first1 = __that.begin();
172 _Literator __last1 = __that.end();
173 _Literator __first2 = __x.begin();
174 _Literator __last2 = __x.end();
175 if (__that.get_allocator() == __x.get_allocator()) {
176 while (__first1 != __last1 && __first2 != __last2) {
177 if (__comp(*__first2, *__first1)) {
178 _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
179 _Literator __next = __first2;
180 _List_global_inst::_Transfer(__first1._M_node, __first2._M_node, (++__next)._M_node);
181 __first2 = __next;
182 }
183 else
184 ++__first1;
185 }
186 if (__first2 != __last2)
187 _List_global_inst::_Transfer(__last1._M_node, __first2._M_node, __last2._M_node);
188 }
189 else {
190 while (__first1 != __last1 && __first2 != __last2) {
191 if (__comp(*__first2, *__first1)) {
192 _STLP_VERBOSE_ASSERT(!__comp(*__first1, *__first2), _StlMsg_INVALID_STRICT_WEAK_PREDICATE)
193 __first1 = __that.insert(__first1, *__first2);
194 }
195 else
196 ++__first1;
197 }
198 if (__first2 != __last2) {
199 __that.insert(__first1, __first2, __last2);
200 }
201 __x.clear();
202 }
203}
#define _STLP_VERBOSE_ASSERT(expr, diagnostic)
Definition: _debug.h:439
static void _STLP_CALL _Transfer(_Node_base *__pos, _Node_base *__first, _Node_base *__last)
allocator_type get_allocator() const
Definition: _list.h:161
iterator begin()
Definition: _list.h:367
_STLP_PRIV _List_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition: _list.h:275
iterator end()
Definition: _list.h:370
void clear()
Definition: _list.h:352
iterator insert(iterator __pos, const_reference __x=value_type())
Definition: _list.h:420

Referenced by list< _Tp, >::merge().

◆ _S_remove_if()

template<class _Tp , class _Alloc , class _Predicate >
_STLP_MOVE_TO_PRIV_NAMESPACE void _S_remove_if ( list< _Tp, _Alloc > &  __that,
_Predicate  __pred 
)

Definition at line 139 of file _list.c.

139 {
140 typedef typename list<_Tp, _Alloc>::iterator _Literator;
141 _Literator __first = __that.begin();
142 _Literator __last = __that.end();
143 while (__first != __last) {
144 _Literator __next = __first;
145 ++__next;
146 if (__pred(*__first)) __that.erase(__first);
147 __first = __next;
148 }
149}
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
_STLP_INLINE_LOOP _InputIter _Predicate __pred
Definition: _algo.h:68
iterator erase(iterator __pos)
Definition: _list.h:518

◆ _S_sort()

template<class _Tp , class _Alloc , class _StrictWeakOrdering >
void _S_sort ( list< _Tp, _Alloc > &  __that,
_StrictWeakOrdering  __comp 
)

Definition at line 206 of file _list.c.

206 {
207 // Do nothing if the list has length 0 or 1.
208 if (__that._M_node._M_data._M_next == &__that._M_node._M_data ||
209 __that._M_node._M_data._M_next->_M_next == &__that._M_node._M_data)
210 return;
211
212 list<_Tp, _Alloc> __carry(__that.get_allocator());
213 const int NB = 64;
214 _STLP_PRIV _CArray<list<_Tp, _Alloc>, NB> __counter(__carry);
215 int __fill = 0;
216 while (!__that.empty()) {
217 __carry.splice(__carry.begin(), __that, __that.begin());
218 int __i = 0;
219 while (__i < __fill && !__counter[__i].empty()) {
220 _S_merge(__counter[__i], __carry, __comp);
221 __carry.swap(__counter[__i++]);
222 }
223 __carry.swap(__counter[__i]);
224 if (__i == __fill) {
225 ++__fill;
226 if (__fill >= NB) {
227 //Looks like the list has too many elements to be sorted with this algorithm:
228 __stl_throw_overflow_error("list::sort");
229 }
230 }
231 }
232
233 for (int __i = 1; __i < __fill; ++__i)
234 _S_merge(__counter[__i], __counter[__i - 1], __comp);
235 __that.swap(__counter[__fill - 1]);
236}
void __fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val, const input_iterator_tag &, _Distance *)
Definition: _algobase.h:417
#define _STLP_PRIV
Definition: _dm.h:70
void _S_merge(list< _Tp, _Alloc > &__that, list< _Tp, _Alloc > &__x, _StrictWeakOrdering __comp)
Definition: _list.c:168
_STLP_THROW_FUNCT_SPEC _STLP_CALL __stl_throw_overflow_error(const char *__msg)
Definition: _range_errors.c:78
Definition: list.h:37
void swap(_Self &__x)
Definition: _list.h:401
bool empty() const
Definition: _list.h:177
static const WCHAR empty[]
Definition: main.c:47

Referenced by list< _Tp, >::sort().

◆ _S_unique()

template<class _Tp , class _Alloc , class _BinaryPredicate >
void _S_unique ( list< _Tp, _Alloc > &  __that,
_BinaryPredicate  __binary_pred 
)

Definition at line 152 of file _list.c.

152 {
153 typedef typename list<_Tp, _Alloc>::iterator _Literator;
154 _Literator __first = __that.begin();
155 _Literator __last = __that.end();
156 if (__first == __last) return;
157 _Literator __next = __first;
158 while (++__next != __last) {
159 if (__binary_pred(*__first, *__next))
160 __that.erase(__next);
161 else
162 __first = __next;
163 __next = __first;
164 }
165}

Referenced by list< _Tp, >::unique().