ReactOS 0.4.15-dev-7924-g5949c20
_slist.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) 1996,1997
4 * Silicon Graphics Computer Systems, Inc.
5 *
6 * Copyright (c) 1997
7 * Moscow Center for SPARC Technology
8 *
9 * Copyright (c) 1999
10 * Boris Fomitchev
11 *
12 * This material is provided "as is", with absolutely no warranty expressed
13 * or implied. Any use is at your own risk.
14 *
15 * Permission to use or copy this software for any purpose is hereby granted
16 * without fee, provided the above notices are retained on all copies.
17 * Permission to modify the code and to distribute modified code is granted,
18 * provided the above notices are retained, and a notice that the code was
19 * modified is included with the above copyright notice.
20 *
21 */
22
23/* NOTE: This is an internal header file, included by other STL headers.
24 * You should not attempt to use it directly.
25 */
26
27#ifndef _STLP_INTERNAL_SLIST_H
28#define _STLP_INTERNAL_SLIST_H
29
30#ifndef _STLP_INTERNAL_ALGOBASE_H
31# include <stl/_algobase.h>
32#endif
33
34#ifndef _STLP_INTERNAL_ALLOC_H
35# include <stl/_alloc.h>
36#endif
37
38#ifndef _STLP_INTERNAL_ITERATOR_H
39# include <stl/_iterator.h>
40#endif
41
42#ifndef _STLP_INTERNAL_CONSTRUCT_H
43# include <stl/_construct.h>
44#endif
45
46#ifndef _STLP_INTERNAL_FUNCTION_BASE_H
47# include <stl/_function_base.h>
48#endif
49
50#ifndef _STLP_INTERNAL_SLIST_BASE_H
51# include <stl/_slist_base.h>
52#endif
53
55
57
58template <class _Tp>
60public:
63};
64
66 typedef size_t size_type;
69
71
72 _Slist_iterator_base(_Slist_node_base *__x) : _M_node(__x) {}
73
74 void _M_incr() {
75 _M_node = _M_node->_M_next;
76 }
77};
78
79template <class _Tp, class _Traits>
81public:
82 typedef typename _Traits::value_type value_type;
83 typedef typename _Traits::pointer pointer;
84 typedef typename _Traits::reference reference;
86 typedef size_t size_type;
88
90 typedef typename _Traits::_NonConstTraits _NonConstTraits;
92 typedef typename _Traits::_ConstTraits _ConstTraits;
94
96
99 //copy constructor for iterator and constructor from iterator for const_iterator
101
102 reference operator*() const { return __STATIC_CAST(_Node*, this->_M_node)->_M_data; }
103
105
107 _M_incr();
108 return *this;
109 }
111 _Self __tmp = *this;
112 _M_incr();
113 return __tmp;
114 }
115
116 bool operator==(const_iterator __y ) const {
117 return this->_M_node == __y._M_node;
118 }
119 bool operator!=(const_iterator __y ) const {
120 return this->_M_node != __y._M_node;
121 }
122};
123
124#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
126template <class _Tp, class _Traits>
127struct __type_traits<_STLP_PRIV _Slist_iterator<_Tp, _Traits> > {
133};
135#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
136
137#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
139template <class _Tp, class _Traits>
140inline _Tp* _STLP_CALL value_type(const _STLP_PRIV _Slist_iterator<_Tp, _Traits>&) { return __STATIC_CAST(_Tp*, 0); }
141inline ptrdiff_t* _STLP_CALL distance_type(const _STLP_PRIV _Slist_iterator_base&) { return 0; }
142inline forward_iterator_tag _STLP_CALL iterator_category(const _STLP_PRIV _Slist_iterator_base&) { return forward_iterator_tag(); }
144#endif /* OLD_QUERIES */
145
146// Base class that encapsulates details of allocators and simplifies EH
147template <class _Tp, class _Alloc>
149protected:
153
154public:
156
159
162 { _M_head._M_data._M_next = 0; }
163
164#if !defined (_STLP_NO_MOVE_SEMANTIC)
167 { src.get()._M_head._M_data._M_next = 0; }
168#endif
169
171
172protected:
174 _Node* __next = __STATIC_CAST(_Node*, __pos->_M_next);
175 _Slist_node_base* __next_next = __next->_M_next;
176 __pos->_M_next = __next_next;
177 _STLP_STD::_Destroy(&__next->_M_data);
178 _M_head.deallocate(__next,1);
179 return __next_next;
180 }
182
183public:
187};
188
189#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
190# define slist _STLP_PTR_IMPL_NAME(slist)
191#elif defined (_STLP_DEBUG)
192# define slist _STLP_NON_DBG_NAME(slist)
193#else
195#endif
196
197template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
198class slist;
199
200#if !defined (slist)
202#endif
203
204// helper functions to reduce code duplication
205template <class _Tp, class _Alloc, class _BinaryPredicate>
206void _Slist_unique(slist<_Tp, _Alloc>& __that, _BinaryPredicate __binary_pred);
207
208template <class _Tp, class _Alloc, class _StrictWeakOrdering>
210 _StrictWeakOrdering __comp);
211
212template <class _Tp, class _Alloc, class _StrictWeakOrdering>
213void _Slist_sort(slist<_Tp, _Alloc>& __that, _StrictWeakOrdering __comp);
214
215#if !defined (slist)
217#endif
218
219template <class _Tp, class _Alloc>
220class slist : protected _STLP_PRIV _Slist_base<_Tp,_Alloc>
221#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (slist)
222 , public __stlport_class<slist<_Tp, _Alloc> >
223#endif
224{
225private:
228public:
229 typedef _Tp value_type;
230
232 typedef const value_type* const_pointer;
235 typedef size_t size_type;
238
241
244
245private:
248
249#if !defined(_STLP_DONT_SUP_DFLT_PARAM)
250 _Node* _M_create_node(const value_type& __x = _Tp()) {
251#else
252 _Node* _M_create_node(const value_type& __x) {
253#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
254 _Node* __node = this->_M_head.allocate(1);
255 _STLP_TRY {
256 _Copy_Construct(&__node->_M_data, __x);
257 __node->_M_next = 0;
258 }
259 _STLP_UNWIND(this->_M_head.deallocate(__node, 1))
260 return __node;
261 }
262
263#if defined(_STLP_DONT_SUP_DFLT_PARAM)
265 _Node* __node = this->_M_head.allocate(1);
266 _STLP_TRY {
267 _STLP_STD::_Construct(&__node->_M_data);
268 __node->_M_next = 0;
269 }
270 _STLP_UNWIND(this->_M_head.deallocate(__node, 1))
271 return __node;
272 }
273#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
274
275public:
276
277 allocator_type get_allocator() const { return _Base::get_allocator(); }
278
279#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
280 explicit slist(const allocator_type& __a = allocator_type())
281#else
282 slist()
284 slist(const allocator_type& __a)
285#endif
287
288#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
290 const allocator_type& __a = allocator_type())
291#else
292 explicit slist(size_type __n)
294 { _M_insert_after_fill(&this->_M_head._M_data, __n, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
295 slist(size_type __n, const value_type& __x)
297 { _M_insert_after_fill(&this->_M_head._M_data, __n, __x); }
298 slist(size_type __n, const value_type& __x, const allocator_type& __a)
299#endif
301 { _M_insert_after_fill(&this->_M_head._M_data, __n, __x); }
302
303#if defined (_STLP_MEMBER_TEMPLATES)
304 // We don't need any dispatching tricks here, because _M_insert_after_range
305 // already does them.
306 template <class _InputIterator>
307 slist(_InputIterator __first, _InputIterator __last,
309 : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a)
310 { _M_insert_after_range(&this->_M_head._M_data, __first, __last); }
311# if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
312 // VC++ needs this crazyness
313 template <class _InputIterator>
314 slist(_InputIterator __first, _InputIterator __last)
316 { _M_insert_after_range(&this->_M_head._M_data, __first, __last); }
317# endif
318#else /* _STLP_MEMBER_TEMPLATES */
320 const allocator_type& __a = allocator_type() )
321 : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a)
322 { _M_insert_after_range(&this->_M_head._M_data, __first, __last); }
323 slist(const value_type* __first, const value_type* __last,
324 const allocator_type& __a = allocator_type())
325 : _STLP_PRIV _Slist_base<_Tp,_Alloc>(__a)
326 { _M_insert_after_range(&this->_M_head._M_data, __first, __last); }
327#endif /* _STLP_MEMBER_TEMPLATES */
328
329 slist(const _Self& __x)
331 { _M_insert_after_range(&this->_M_head._M_data, __x.begin(), __x.end()); }
332
333#if !defined (_STLP_NO_MOVE_SEMANTIC)
336#endif
337
338 _Self& operator= (const _Self& __x);
339
341
342public:
343 // assign(), a generalized assignment member function. Two
344 // versions: one that takes a count, and one that takes a range.
345 // The range version is a member template, so we dispatch on whether
346 // or not the type is an integer.
347
349
350private:
351 void _M_fill_assign(size_type __n, const _Tp& __val);
352
353#if defined (_STLP_MEMBER_TEMPLATES)
354public:
355 template <class _InputIterator>
356 void assign(_InputIterator __first, _InputIterator __last) {
357 typedef typename _IsIntegral<_InputIterator>::_Ret _Integral;
358 _M_assign_dispatch(__first, __last, _Integral());
359 }
360
361private:
362 template <class _Integer>
363 void _M_assign_dispatch(_Integer __n, _Integer __val,
364 const __true_type& /*_IsIntegral*/) {
366 }
367
368 template <class _InputIter>
369 void _M_assign_dispatch(_InputIter __first, _InputIter __last,
370 const __false_type& /*_IsIntegral*/) {
371#else
372public:
374 _Node_base* __prev = &this->_M_head._M_data;
375 _Node_base* __node = this->_M_head._M_data._M_next;
376 while (__node != 0 && __first != __last) {
377 __STATIC_CAST(_Node*, __node)->_M_data = *__first;
378 __prev = __node;
379 __node = __node->_M_next;
380 ++__first;
381 }
382 if (__first != __last)
383 _M_insert_after_range(__prev, __first, __last);
384 else
385 this->_M_erase_after(__prev, 0);
386 }
388#endif /* _STLP_MEMBER_TEMPLATES */
389 _Node_base* __prev = &this->_M_head._M_data;
390 _Node_base* __node = this->_M_head._M_data._M_next;
391 while (__node != 0 && __first != __last) {
392 __STATIC_CAST(_Node*, __node)->_M_data = *__first;
393 __prev = __node;
394 __node = __node->_M_next;
395 ++__first;
396 }
397 if (__first != __last)
398 _M_insert_after_range(__prev, __first, __last);
399 else
400 this->_M_erase_after(__prev, 0);
401 }
402
403public:
404
405 // Experimental new feature: before_begin() returns a
406 // non-dereferenceable iterator that, when incremented, yields
407 // begin(). This iterator may be used as the argument to
408 // insert_after, erase_after, etc. Note that even for an empty
409 // slist, before_begin() is not the same iterator as end(). It
410 // is always necessary to increment before_begin() at least once to
411 // obtain end().
412 iterator before_begin() { return iterator(&this->_M_head._M_data); }
414 { return const_iterator(__CONST_CAST(_Node_base*, &this->_M_head._M_data)); }
415
416 iterator begin() { return iterator(this->_M_head._M_data._M_next); }
418 { return const_iterator(this->_M_head._M_data._M_next);}
419
420 iterator end() { return iterator(); }
421 const_iterator end() const { return const_iterator(); }
422
424 { return _STLP_PRIV _Sl_global_inst::size(this->_M_head._M_data._M_next); }
425
426 size_type max_size() const { return size_type(-1); }
427
428 bool empty() const { return this->_M_head._M_data._M_next == 0; }
429
430 void swap(_Self& __x)
431 { this->_M_head.swap(__x._M_head); }
432#if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
433 void _M_swap_workaround(_Self& __x) { swap(__x); }
434#endif
435
436public:
437 reference front() { return *begin(); }
438 const_reference front() const { return *begin(); }
439#if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
440 void push_front(const value_type& __x = _Tp()) {
441#else
442 void push_front(const value_type& __x) {
443#endif
444 _STLP_PRIV __slist_make_link(&this->_M_head._M_data, _M_create_node(__x));
445 }
446
447#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
448 void push_front() { _STLP_PRIV __slist_make_link(&this->_M_head._M_data, _M_create_node());}
449#endif /*_STLP_DONT_SUP_DFLT_PARAM && !_STLP_NO_ANACHRONISMS*/
450
451 void pop_front() {
452 _Node* __node = __STATIC_CAST(_Node*, this->_M_head._M_data._M_next);
453 this->_M_head._M_data._M_next = __node->_M_next;
454 _STLP_STD::_Destroy(&__node->_M_data);
455 this->_M_head.deallocate(__node, 1);
456 }
457
459 return iterator(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node));
460 }
463 _STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data,
464 __pos._M_node)));
465 }
466
467private:
468#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
469 _Node* _M_insert_after(_Node_base* __pos, const value_type& __x = _Tp()) {
470#else
471 _Node* _M_insert_after(_Node_base* __pos, const value_type& __x) {
472#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
474 }
475
476#if defined (_STLP_DONT_SUP_DFLT_PARAM)
479 }
480#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
481
483 size_type __n, const value_type& __x) {
484 for (size_type __i = 0; __i < __n; ++__i)
485 __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(__x));
486 }
487
488#if defined (_STLP_MEMBER_TEMPLATES)
489 // Check whether it's an integral type. If so, it's not an iterator.
490 template <class _InIter>
492 _InIter __first, _InIter __last) {
493 typedef typename _IsIntegral<_InIter>::_Ret _Integral;
494 _M_insert_after_range(__pos, __first, __last, _Integral());
495 }
496
497 template <class _Integer>
498 void _M_insert_after_range(_Node_base* __pos, _Integer __n, _Integer __x,
499 const __true_type&) {
500 _M_insert_after_fill(__pos, __n, __x);
501 }
502
503 template <class _InIter>
505 _InIter __first, _InIter __last,
506 const __false_type&) {
507#else /* _STLP_MEMBER_TEMPLATES */
509 const value_type* __first,
510 const value_type* __last) {
511 while (__first != __last) {
512 __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first));
513 ++__first;
514 }
515 }
518#endif /* _STLP_MEMBER_TEMPLATES */
519 while (__first != __last) {
520 __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first));
521 ++__first;
522 }
523 }
524
525#if defined (_STLP_MEMBER_TEMPLATES)
526 // Check whether it's an integral type. If so, it's not an iterator.
527 template <class _InIter>
529 _InIter __first, _InIter __last) {
530 typedef typename _IsIntegral<_InIter>::_Ret _Integral;
531 _M_splice_after_range(__pos, __first, __last, _Integral());
532 }
533
534 template <class _Integer>
535 void _M_splice_after_range(_Node_base* __pos, _Integer __n, _Integer __x,
536 const __true_type&) {
537 _M_insert_after_fill(__pos, __n, __x);
538 }
539
540 template <class _InIter>
542 _InIter __first, _InIter __last,
543 const __false_type&) {
544#else /* _STLP_MEMBER_TEMPLATES */
546 const value_type* __first,
547 const value_type* __last) {
548 while (__first != __last) {
549 __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first));
550 ++__first;
551 }
552 }
555#endif /* _STLP_MEMBER_TEMPLATES */
556 //We use a temporary slist to avoid the auto reference troubles (infinite loop)
557 _Self __tmp(__first, __last, this->get_allocator());
558 splice_after(iterator(__pos), __tmp);
559 }
560
561#if defined (_STLP_MEMBER_TEMPLATES)
562 // Check whether it's an integral type. If so, it's not an iterator.
563 template <class _InIter>
564 void _M_splice_range(_Node_base* __pos,
565 _InIter __first, _InIter __last) {
566 typedef typename _IsIntegral<_InIter>::_Ret _Integral;
567 _M_splice_range(__pos, __first, __last, _Integral());
568 }
569
570 template <class _Integer>
571 void _M_splice_range(_Node_base* __pos, _Integer __n, _Integer __x,
572 const __true_type&) {
573 _M_insert_after_fill(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos),
574 __n, __x);
575 }
576
577 template <class _InIter>
578 void _M_splice_range(_Node_base* __pos,
579 _InIter __first, _InIter __last,
580 const __false_type&) {
581#else /* _STLP_MEMBER_TEMPLATES */
583 const value_type* __first,
584 const value_type* __last) {
585 while (__first != __last) {
586 __pos = _STLP_PRIV __slist_make_link(__pos, _M_create_node(*__first));
587 ++__first;
588 }
589 }
592#endif /* _STLP_MEMBER_TEMPLATES */
593 //We use a temporary slist to avoid the auto reference troubles (infinite loop)
594 _Self __tmp(__first, __last, this->get_allocator());
595 splice(iterator(__pos), __tmp);
596 }
597
598public:
599
600#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
601 iterator insert_after(iterator __pos, const value_type& __x = _Tp()) {
602#else
603 iterator insert_after(iterator __pos, const value_type& __x) {
604#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
605 return iterator(_M_insert_after(__pos._M_node, __x));
606 }
607
608#if defined (_STLP_DONT_SUP_DFLT_PARAM)
610 return insert_after(__pos, _STLP_DEFAULT_CONSTRUCTED(_Tp));
611 }
612#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
613
614 void insert_after(iterator __pos, size_type __n, const value_type& __x) {
615 _M_insert_after_fill(__pos._M_node, __n, __x);
616 }
617
618#if defined (_STLP_MEMBER_TEMPLATES)
619 // We don't need any dispatching tricks here, because _M_insert_after_range
620 // already does them.
621 template <class _InIter>
622 void insert_after(iterator __pos, _InIter __first, _InIter __last) {
623#else /* _STLP_MEMBER_TEMPLATES */
625 const value_type* __first, const value_type* __last) {
626 _M_insert_after_range(__pos._M_node, __first, __last);
627 }
630#endif /* _STLP_MEMBER_TEMPLATES */
631 _M_splice_after_range(__pos._M_node, __first, __last);
632 }
633
634#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
635 iterator insert(iterator __pos, const value_type& __x = _Tp()) {
636#else
637 iterator insert(iterator __pos, const value_type& __x) {
638#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
639 return iterator(_M_insert_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node),
640 __x));
641 }
642
643#if defined (_STLP_DONT_SUP_DFLT_PARAM)
644 iterator insert(iterator __pos) {
645 return iterator(_M_insert_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node),
647 }
648#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
649
650 void insert(iterator __pos, size_type __n, const value_type& __x) {
651 _M_insert_after_fill(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node), __n, __x);
652 }
653
654#if defined (_STLP_MEMBER_TEMPLATES)
655 // We don't need any dispatching tricks here, because _M_insert_after_range
656 // already does them.
657 template <class _InIter>
658 void insert(iterator __pos, _InIter __first, _InIter __last) {
659#else /* _STLP_MEMBER_TEMPLATES */
660 void insert(iterator __pos, const value_type* __first,
661 const value_type* __last) {
662 _M_insert_after_range(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node),
663 __first, __last);
664 }
666#endif /* _STLP_MEMBER_TEMPLATES */
667 _M_splice_range(__pos._M_node, __first, __last);
668 }
669
670public:
672 { return iterator(this->_M_erase_after(__pos._M_node)); }
674 { return iterator(this->_M_erase_after(__before_first._M_node, __last._M_node)); }
675
677 { return iterator(this->_M_erase_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __pos._M_node))); }
679 { return iterator(this->_M_erase_after(_STLP_PRIV _Sl_global_inst::__previous(&this->_M_head._M_data, __first._M_node), __last._M_node)); }
680
681#if !defined (_STLP_DONT_SUP_DFLT_PARAM)
682 void resize(size_type new_size, const value_type& __x = _Tp());
683#else
684 void resize(size_type new_size, const value_type& __x);
685#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
686
687#if defined (_STLP_DONT_SUP_DFLT_PARAM)
688 void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
689#endif /*_STLP_DONT_SUP_DFLT_PARAM*/
690
691 void clear()
692 { this->_M_erase_after(&this->_M_head._M_data, 0); }
693
694public:
695 // Moves the range [__before_first + 1, __before_last + 1) to *this,
696 // inserting it immediately after __pos. This is constant time.
697 void splice_after(iterator __pos, _Self& __x,
698 iterator __before_first, iterator __before_last) {
699 if (__before_first != __before_last) {
700 if (this->get_allocator() == __x.get_allocator()) {
702 __before_first._M_node, __before_last._M_node);
703 }
704 else {
705 this->insert_after(__pos, iterator(__before_first._M_node->_M_next), iterator(__before_last._M_node->_M_next));
706 __x.erase_after(__before_first, ++__before_last);
707 }
708 }
709 }
710
711 // Moves the element that follows __prev to *this, inserting it immediately
712 // after __pos. This is constant time.
713 void splice_after(iterator __pos, _Self& __x, iterator __prev) {
714 if (this->get_allocator() == __x.get_allocator()) {
716 __prev._M_node, __prev._M_node->_M_next);
717 }
718 else {
719 this->insert_after(__pos, __STATIC_CAST(_Node*, __prev._M_node->_M_next)->_M_data);
720 __x.erase_after(__prev);
721 }
722 }
723
724 // Removes all of the elements from the list __x to *this, inserting
725 // them immediately after __pos. __x must not be *this. Complexity:
726 // linear in __x.size().
727 void splice_after(iterator __pos, _Self& __x) {
728 if (this->get_allocator() == __x.get_allocator())
729 _STLP_PRIV _Sl_global_inst::__splice_after(__pos._M_node, &__x._M_head._M_data);
730 else {
731 this->insert_after(__pos, __x.begin(), __x.end());
732 __x.clear();
733 }
734 }
735
736 // Linear in distance(begin(), __pos), and linear in __x.size().
737 void splice(iterator __pos, _Self& __x) {
738 if (__x._M_head._M_data._M_next) {
739 if (this->get_allocator() == __x.get_allocator()) {
741 &__x._M_head._M_data,
742 _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, 0));
743 }
744 else {
745 insert(__pos, __x.begin(), __x.end());
746 __x.clear();
747 }
748 }
749 }
750
751 // Linear in distance(begin(), __pos), and in distance(__x.begin(), __i).
752 void splice(iterator __pos, _Self& __x, iterator __i) {
753 if (this->get_allocator() == __x.get_allocator()) {
755 _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, __i._M_node),
756 __i._M_node);
757 }
758 else {
759 insert(__pos, *__i);
760 __x.erase(__i);
761 }
762 }
763
764 // Linear in distance(begin(), __pos), in distance(__x.begin(), __first),
765 // and in distance(__first, __last).
766 void splice(iterator __pos, _Self& __x, iterator __first, iterator __last) {
767 if (__first != __last) {
768 if (this->get_allocator() == __x.get_allocator()) {
770 _STLP_PRIV _Sl_global_inst::__previous(&__x._M_head._M_data, __first._M_node),
771 _STLP_PRIV _Sl_global_inst::__previous(__first._M_node, __last._M_node));
772 }
773 else {
774 insert(__pos, __first, __last);
775 __x.erase(__first, __last);
776 }
777 }
778 }
779
780public:
781 void reverse() {
782 if (this->_M_head._M_data._M_next)
783 this->_M_head._M_data._M_next = _STLP_PRIV _Sl_global_inst::__reverse(this->_M_head._M_data._M_next);
784 }
785
786 void remove(const _Tp& __val);
787
789 void merge(_Self& __x) { _STLP_PRIV _Slist_merge(*this, __x, less<value_type>()); }
791
792#if defined (_STLP_MEMBER_TEMPLATES)
793 template <class _Predicate>
794 void remove_if(_Predicate __pred) {
795 _Node_base* __cur = &this->_M_head._M_data;
796 while (__cur->_M_next) {
797 if (__pred(__STATIC_CAST(_Node*, __cur->_M_next)->_M_data))
798 this->_M_erase_after(__cur);
799 else
800 __cur = __cur->_M_next;
801 }
802 }
803
804 template <class _BinaryPredicate>
805 void unique(_BinaryPredicate __pred)
806 { _STLP_PRIV _Slist_unique(*this, __pred); }
807
808 template <class _StrictWeakOrdering>
809 void merge(_Self& __x, _StrictWeakOrdering __comp)
810 { _STLP_PRIV _Slist_merge(*this, __x, __comp); }
811
812 template <class _StrictWeakOrdering>
813 void sort(_StrictWeakOrdering __comp)
814 { _STLP_PRIV _Slist_sort(*this, __comp); }
815#endif /* _STLP_MEMBER_TEMPLATES */
816};
817
818#if defined (slist)
819# undef slist
821#endif
822
824
825#if !defined (_STLP_LINK_TIME_INSTANTIATION)
826# include <stl/_slist.c>
827#endif
828
829#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
830# include <stl/pointers/_slist.h>
831#endif
832
833#if defined (_STLP_DEBUG)
834# include <stl/debug/_slist.h>
835#endif
836
838
839template <class _Tp, class _Alloc>
840inline bool _STLP_CALL
843 const_iterator __end1 = _SL1.end();
844 const_iterator __end2 = _SL2.end();
845
846 const_iterator __i1 = _SL1.begin();
847 const_iterator __i2 = _SL2.begin();
848 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
849 ++__i1;
850 ++__i2;
851 }
852 return __i1 == __end1 && __i2 == __end2;
853}
854
855#define _STLP_EQUAL_OPERATOR_SPECIALIZED
856#define _STLP_TEMPLATE_HEADER template <class _Tp, class _Alloc>
857#define _STLP_TEMPLATE_CONTAINER slist<_Tp, _Alloc>
858#include <stl/_relops_cont.h>
859#undef _STLP_TEMPLATE_CONTAINER
860#undef _STLP_TEMPLATE_HEADER
861#undef _STLP_EQUAL_OPERATOR_SPECIALIZED
862
863#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
864# if !defined (_STLP_NO_MOVE_SEMANTIC)
865template <class _Tp, class _Alloc>
866struct __move_traits<slist<_Tp, _Alloc> > {
867 typedef __true_type implemented;
869};
870# endif
871
872// Specialization of insert_iterator so that insertions will be constant
873// time rather than linear time.
874template <class _Tp, class _Alloc>
875class insert_iterator<slist<_Tp, _Alloc> > {
876protected:
877 typedef slist<_Tp, _Alloc> _Container;
878 _Container* _M_container;
879 typename _Container::iterator _M_iter;
880public:
881 typedef _Container container_type;
882 typedef output_iterator_tag iterator_category;
883 typedef void value_type;
884 typedef void difference_type;
885 typedef void pointer;
886 typedef void reference;
887
888 insert_iterator(_Container& __x, typename _Container::iterator __i)
889 : _M_container(&__x) {
890 if (__i == __x.begin())
891 _M_iter = __x.before_begin();
892 else
893 _M_iter = __x.previous(__i);
894 }
895
897 operator = (const typename _Container::value_type& __val) {
898 _M_iter = _M_container->insert_after(_M_iter, __val);
899 return *this;
900 }
901
902 insert_iterator<_Container>& operator*() { return *this; }
903 insert_iterator<_Container>& operator++() { return *this; }
904 insert_iterator<_Container>& operator++(int) { return *this; }
905};
906#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
907
909
910#endif /* _STLP_INTERNAL_SLIST_H */
911
912// Local Variables:
913// mode:C++
914// End:
_STLP_INLINE_LOOP _InputIter __last
Definition: _algo.h:68
_STLP_INLINE_LOOP _InputIter _Predicate __pred
Definition: _algo.h:68
_STLP_INLINE_LOOP _ForwardIter remove_if(_ForwardIter __first, _ForwardIter __last, _Predicate __pred)
Definition: _algo.h:278
return __n
Definition: _algo.h:75
_STLP_INLINE_LOOP _InputIter const _Tp & __val
Definition: _algobase.h:656
#define _STLP_CONVERT_ALLOCATOR(__a, _Tp)
Definition: _alloc.h:183
#define _STLP_FORCE_ALLOCATORS(a, y)
Definition: _alloc.h:436
#define _STLP_CALL
Definition: _bc.h:131
#define _Alloc
Definition: _bvector.h:330
complex< _Tp > _STLP_CALL operator*(const _Tp &__x, const complex< _Tp > &__z)
Definition: _complex.h:644
void _Copy_Construct(_Tp *__p, const _Tp &__val)
Definition: _construct.h:130
#define _STLP_DEFAULT_CONSTRUCTED(_TTp)
Definition: _construct.h:265
#define _STLP_PRIV
Definition: _dm.h:70
#define _STLP_DEFINE_ARROW_OPERATOR
void _Slist_merge(slist< _Tp, _Alloc > &__that, slist< _Tp, _Alloc > &__x, _StrictWeakOrdering __comp)
Definition: _slist.c:148
void _Slist_sort(slist< _Tp, _Alloc > &__that, _StrictWeakOrdering __comp)
Definition: _slist.c:184
_STLP_MOVE_TO_PRIV_NAMESPACE void _Slist_unique(slist< _Tp, _Alloc > &__that, _BinaryPredicate __pred)
Definition: _slist.c:134
void _Slist_merge(slist< _Tp, _Alloc > &__that, slist< _Tp, _Alloc > &__x, _StrictWeakOrdering __comp)
Definition: _slist.c:148
_STLP_MOVE_TO_PRIV_NAMESPACE void _Slist_unique(slist< _Tp, _Alloc > &__that, _BinaryPredicate __binary_pred)
Definition: _slist.c:134
void _Slist_sort(slist< _Tp, _Alloc > &__that, _StrictWeakOrdering __comp)
Definition: _slist.c:184
_Slist_node_base * __slist_make_link(_Slist_node_base *__prev_node, _Slist_node_base *__new_node)
Definition: _slist_base.h:43
void get(int argc, const char *argv[])
Definition: cmds.c:480
_Value _M_data
Definition: _alloc.h:478
static size_t _STLP_CALL size(_Slist_node_base *__node)
Definition: _slist_base.c:89
static _Slist_node_base *_STLP_CALL __previous(_Slist_node_base *__head, const _Slist_node_base *__node)
Definition: _slist_base.c:39
static void _STLP_CALL __splice_after(_Slist_node_base *__pos, _Slist_node_base *__before_first, _Slist_node_base *__before_last)
Definition: _slist_base.c:60
static _Slist_node_base *_STLP_CALL __reverse(_Slist_node_base *__node)
Definition: _slist_base.c:74
_Slist_node_base * _M_erase_after(_Slist_node_base *__pos)
Definition: _slist.h:173
allocator_type get_allocator() const
Definition: _slist.h:184
_Slist_base< _Tp, _Alloc > _Self
Definition: _slist.h:152
_Slist_node< _Tp > _Node
Definition: _slist.h:150
_Alloc allocator_type
Definition: _slist.h:158
_STLP_alloc_proxy< _Slist_node_base, _Node, _M_node_allocator_type > _AllocProxy
Definition: _slist.h:155
~_Slist_base()
Definition: _slist.h:170
_Alloc_traits< _Node, _Alloc >::allocator_type _M_node_allocator_type
Definition: _slist.h:151
_Slist_base(__move_source< _Self > src)
Definition: _slist.h:165
_AllocProxy _M_head
Definition: _slist.h:186
_Slist_iterator< _Tp, _Traits > _Self
Definition: _slist.h:89
_Slist_node< value_type > _Node
Definition: _slist.h:95
_Slist_iterator< _Tp, _NonConstTraits > iterator
Definition: _slist.h:91
_Slist_iterator()
Definition: _slist.h:98
_Traits::reference reference
Definition: _slist.h:84
_Slist_iterator(_Slist_node_base *__x)
Definition: _slist.h:97
_Traits::value_type value_type
Definition: _slist.h:82
bool operator==(const_iterator __y) const
Definition: _slist.h:116
size_t size_type
Definition: _slist.h:86
_Traits::pointer pointer
Definition: _slist.h:83
_Traits::_NonConstTraits _NonConstTraits
Definition: _slist.h:90
_Slist_iterator(const iterator &__x)
Definition: _slist.h:100
ptrdiff_t difference_type
Definition: _slist.h:87
_Self operator++(int)
Definition: _slist.h:110
bool operator!=(const_iterator __y) const
Definition: _slist.h:119
forward_iterator_tag iterator_category
Definition: _slist.h:85
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
Definition: _slist.h:106
_Traits::_ConstTraits _ConstTraits
Definition: _slist.h:92
_Slist_iterator< _Tp, _ConstTraits > const_iterator
Definition: _slist.h:93
reference operator*() const
Definition: _slist.h:102
_Tp _M_data
Definition: _slist.h:61
Definition: _slist.h:57
void merge(_Self &__x)
Definition: _slist.h:789
_Self & operator=(const _Self &__x)
Definition: _slist.c:70
void _M_splice_range(_Node_base *__pos, const value_type *__first, const value_type *__last)
Definition: _slist.h:582
const_iterator end() const
Definition: _slist.h:421
void swap(_Self &__x)
Definition: _slist.h:430
const value_type * const_pointer
Definition: _slist.h:232
void insert(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _slist.h:665
_STLP_PRIV _Slist_iterator< _Tp, _Nonconst_traits< _Tp > > iterator
Definition: _slist.h:239
iterator erase_after(iterator __before_first, iterator __last)
Definition: _slist.h:673
void resize(size_type new_size, const value_type &__x=_Tp())
Definition: _slist.c:106
iterator end()
Definition: _slist.h:420
_Node * _M_insert_after(_Node_base *__pos, const value_type &__x=_Tp())
Definition: _slist.h:469
~slist()
Definition: _slist.h:340
slist(const_iterator __first, const_iterator __last, const allocator_type &__a=allocator_type())
Definition: _slist.h:319
size_t size_type
Definition: _slist.h:235
void insert(iterator __pos, const value_type *__first, const value_type *__last)
Definition: _slist.h:660
iterator erase(iterator __pos)
Definition: _slist.h:676
_Node * _M_create_node(const value_type &__x=_Tp())
Definition: _slist.h:250
void unique()
Definition: _slist.h:788
void splice_after(iterator __pos, _Self &__x, iterator __before_first, iterator __before_last)
Definition: _slist.h:697
void splice(iterator __pos, _Self &__x, iterator __first, iterator __last)
Definition: _slist.h:766
size_type size() const
Definition: _slist.h:423
void clear()
Definition: _slist.h:691
void _M_fill_assign(size_type __n, const _Tp &__val)
Definition: _slist.c:91
iterator erase(iterator __first, iterator __last)
Definition: _slist.h:678
_Base::allocator_type allocator_type
Definition: _slist.h:243
const value_type & const_reference
Definition: _slist.h:234
void _M_splice_after_range(_Node_base *__pos, const_iterator __first, const_iterator __last)
Definition: _slist.h:553
value_type * pointer
Definition: _slist.h:231
size_type max_size() const
Definition: _slist.h:426
const_reference front() const
Definition: _slist.h:438
void insert_after(iterator __pos, const value_type *__first, const value_type *__last)
Definition: _slist.h:624
void assign(const_pointer __first, const_pointer __last)
Definition: _slist.h:373
void _M_insert_after_range(_Node_base *__pos, const_iterator __first, const_iterator __last)
Definition: _slist.h:516
iterator insert_after(iterator __pos, const value_type &__x=_Tp())
Definition: _slist.h:601
slist(const value_type *__first, const value_type *__last, const allocator_type &__a=allocator_type())
Definition: _slist.h:323
slist(size_type __n, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp), const allocator_type &__a=allocator_type())
Definition: _slist.h:289
slist(__move_source< _Self > src)
Definition: _slist.h:334
iterator insert(iterator __pos, const value_type &__x=_Tp())
Definition: _slist.h:635
void push_front(const value_type &__x=_Tp())
Definition: _slist.h:440
iterator before_begin()
Definition: _slist.h:412
_STLP_PRIV _Slist_node< _Tp > _Node
Definition: _slist.h:246
iterator erase_after(iterator __pos)
Definition: _slist.h:671
void _M_splice_range(_Node_base *__pos, const_iterator __first, const_iterator __last)
Definition: _slist.h:590
forward_iterator_tag _Iterator_category
Definition: _slist.h:237
const_iterator before_begin() const
Definition: _slist.h:413
allocator_type get_allocator() const
Definition: _slist.h:277
void assign(const_iterator __first, const_iterator __last)
Definition: _slist.h:387
void assign(size_type __n, const _Tp &__val)
Definition: _slist.h:348
const_iterator begin() const
Definition: _slist.h:417
void _M_insert_after_range(_Node_base *__pos, const value_type *__first, const value_type *__last)
Definition: _slist.h:508
void insert_after(iterator __pos, size_type __n, const value_type &__x)
Definition: _slist.h:614
reference front()
Definition: _slist.h:437
_STLP_PRIV _Slist_node_base _Node_base
Definition: _slist.h:247
void reverse()
Definition: _slist.h:781
void _M_splice_after_range(_Node_base *__pos, const value_type *__first, const value_type *__last)
Definition: _slist.h:545
void pop_front()
Definition: _slist.h:451
void splice_after(iterator __pos, _Self &__x)
Definition: _slist.h:727
void sort()
Definition: _slist.h:790
void _M_insert_after_fill(_Node_base *__pos, size_type __n, const value_type &__x)
Definition: _slist.h:482
void insert_after(iterator __pos, const_iterator __first, const_iterator __last)
Definition: _slist.h:628
void insert(iterator __pos, size_type __n, const value_type &__x)
Definition: _slist.h:650
_STLP_PRIV _Slist_iterator< _Tp, _Const_traits< _Tp > > const_iterator
Definition: _slist.h:240
bool empty() const
Definition: _slist.h:428
void splice(iterator __pos, _Self &__x)
Definition: _slist.h:737
slist(const allocator_type &__a=allocator_type())
Definition: _slist.h:280
iterator begin()
Definition: _slist.h:416
slist< _Tp, _Alloc > _Self
Definition: _slist.h:227
value_type & reference
Definition: _slist.h:233
_STLP_PRIV _Slist_base< _Tp, _Alloc > _Base
Definition: _slist.h:226
void splice(iterator __pos, _Self &__x, iterator __i)
Definition: _slist.h:752
void splice_after(iterator __pos, _Self &__x, iterator __prev)
Definition: _slist.h:713
iterator previous(const_iterator __pos)
Definition: _slist.h:458
slist(const _Self &__x)
Definition: _slist.h:329
const_iterator previous(const_iterator __pos) const
Definition: _slist.h:461
_Tp value_type
Definition: _slist.h:229
ptrdiff_t difference_type
Definition: _slist.h:236
container_type
Definition: metafile.c:147
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_UNWIND(action)
Definition: features.h:824
#define __TRIVIAL_STUFF(__type)
Definition: features.h:799
#define _STLP_MOVE_TO_STD_NAMESPACE
Definition: features.h:525
#define __STATIC_CAST(__x, __y)
Definition: features.h:585
#define _STLP_ALLOCATOR_TYPE_DFL
Definition: features.h:691
#define _STLP_TRY
Definition: features.h:817
#define __CONST_CAST(__x, __y)
Definition: features.h:584
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define _STLP_MOVE_TO_PRIV_NAMESPACE
Definition: features.h:524
char typename[32]
Definition: main.c:84
GLenum src
Definition: glext.h:6340
GLsizei const GLvoid * pointer
Definition: glext.h:5848
GLint reference
Definition: glext.h:11729
static BOOL complete
Definition: htmldoc.c:198
int remove
Definition: msacm.c:1366
#define swap(a, b)
Definition: qsort.c:63
_Rebind_type::other allocator_type
Definition: _alloc.h:201
_Slist_iterator_base(_Slist_node_base *__x)
Definition: _slist.h:72
_Slist_node_base * _M_node
Definition: _slist.h:70
ptrdiff_t difference_type
Definition: _slist.h:67
size_t size_type
Definition: _slist.h:66
forward_iterator_tag iterator_category
Definition: _slist.h:68
_Slist_node_base * _M_next
Definition: _slist_base.h:39
__bool2type< pod >::_Ret is_POD_type
__bool2type< trivial_destructor >::_Ret has_trivial_destructor
__bool2type< trivial_constructor >::_Ret has_trivial_default_constructor
__bool2type< trivial_copy >::_Ret has_trivial_copy_constructor
__bool2type< trivial_assign >::_Ret has_trivial_assignment_operator
bool operator==(const TKeyDef &t1, const TKeyDef &t2)
Definition: tkeydef.cpp:122
static int insert
Definition: xmllint.c:138
#define const
Definition: zconf.h:233