- void remove(const _Tp& __val);
- void unique();
- void merge(slist& __x);
- void sort();
-
- template <class _Predicate>
- void remove_if(_Predicate __pred);
-
- template <class _BinaryPredicate>
- void unique(_BinaryPredicate __pred);
-
- template <class _StrictWeakOrdering>
- void merge(slist&, _StrictWeakOrdering);
-
- template <class _StrictWeakOrdering>
- void sort(_StrictWeakOrdering __comp);
-};
-
-template <class _Tp, class _Alloc>
-slist<_Tp,_Alloc>& slist<_Tp,_Alloc>::operator=(const slist<_Tp,_Alloc>& __x)
-{
- if (&__x != this) {
- _Node_base* __p1 = &this->_M_head;
- _Node* __n1 = (_Node*) this->_M_head._M_next;
- const _Node* __n2 = (const _Node*) __x._M_head._M_next;
- while (__n1 && __n2) {
- __n1->_M_data = __n2->_M_data;
- __p1 = __n1;
- __n1 = (_Node*) __n1->_M_next;
- __n2 = (const _Node*) __n2->_M_next;
- }
- if (__n2 == 0)
- this->_M_erase_after(__p1, 0);
- else
- _M_insert_after_range(__p1, const_iterator((_Node*)__n2),
- const_iterator(0));
- }
- return *this;
-}
-
-template <class _Tp, class _Alloc>
-void slist<_Tp, _Alloc>::_M_fill_assign(size_type __n, const _Tp& __val) {
- _Node_base* __prev = &this->_M_head;
- _Node* __node = (_Node*) this->_M_head._M_next;
- for ( ; __node != 0 && __n > 0 ; --__n) {
- __node->_M_data = __val;
- __prev = __node;
- __node = (_Node*) __node->_M_next;
- }
- if (__n > 0)
- _M_insert_after_fill(__prev, __n, __val);
- else
- this->_M_erase_after(__prev, 0);
-}
-
-template <class _Tp, class _Alloc> template <class _InputIter>
-void
-slist<_Tp, _Alloc>::_M_assign_dispatch(_InputIter __first, _InputIter __last,
- __false_type)
-{
- _Node_base* __prev = &this->_M_head;
- _Node* __node = (_Node*) this->_M_head._M_next;
- while (__node != 0 && __first != __last) {
- __node->_M_data = *__first;
- __prev = __node;
- __node = (_Node*) __node->_M_next;
- ++__first;
- }
- if (__first != __last)
- _M_insert_after_range(__prev, __first, __last);
- else
- this->_M_erase_after(__prev, 0);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator==(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2)
-{
- typedef typename slist<_Tp,_Alloc>::const_iterator const_iterator;
- const_iterator __end1 = _SL1.end();
- const_iterator __end2 = _SL2.end();
-
- const_iterator __i1 = _SL1.begin();
- const_iterator __i2 = _SL2.begin();
- while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2) {
- ++__i1;
- ++__i2;
- }
- return __i1 == __end1 && __i2 == __end2;
-}
-
-
-template <class _Tp, class _Alloc>
-inline bool
-operator<(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2)
-{
- return lexicographical_compare(_SL1.begin(), _SL1.end(),
- _SL2.begin(), _SL2.end());
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator!=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {
- return !(_SL1 == _SL2);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator>(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {
- return _SL2 < _SL1;
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator<=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {
- return !(_SL2 < _SL1);
-}
-
-template <class _Tp, class _Alloc>
-inline bool
-operator>=(const slist<_Tp,_Alloc>& _SL1, const slist<_Tp,_Alloc>& _SL2) {
- return !(_SL1 < _SL2);
-}
-
-template <class _Tp, class _Alloc>
-inline void swap(slist<_Tp,_Alloc>& __x, slist<_Tp,_Alloc>& __y) {
- __x.swap(__y);
-}
-
-
-template <class _Tp, class _Alloc>
-void slist<_Tp,_Alloc>::resize(size_type __len, const _Tp& __x)
-{
- _Node_base* __cur = &this->_M_head;
- while (__cur->_M_next != 0 && __len > 0) {
- --__len;
- __cur = __cur->_M_next;
- }
- if (__cur->_M_next)
- this->_M_erase_after(__cur, 0);
- else
- _M_insert_after_fill(__cur, __len, __x);
-}
-
-template <class _Tp, class _Alloc>
-void slist<_Tp,_Alloc>::remove(const _Tp& __val)
-{
- _Node_base* __cur = &this->_M_head;
- while (__cur && __cur->_M_next) {
- if (((_Node*) __cur->_M_next)->_M_data == __val)
- this->_M_erase_after(__cur);
- else
- __cur = __cur->_M_next;
- }
-}
-
-template <class _Tp, class _Alloc>
-void slist<_Tp,_Alloc>::unique()
-{
- _Node_base* __cur = this->_M_head._M_next;
- if (__cur) {
- while (__cur->_M_next) {
- if (((_Node*)__cur)->_M_data ==
- ((_Node*)(__cur->_M_next))->_M_data)
- this->_M_erase_after(__cur);
- else
- __cur = __cur->_M_next;
- }
- }
-}
-
-template <class _Tp, class _Alloc>
-void slist<_Tp,_Alloc>::merge(slist<_Tp,_Alloc>& __x)
-{
- _Node_base* __n1 = &this->_M_head;
- while (__n1->_M_next && __x._M_head._M_next) {
- if (((_Node*) __x._M_head._M_next)->_M_data <
- ((_Node*) __n1->_M_next)->_M_data)
- __slist_splice_after(__n1, &__x._M_head, __x._M_head._M_next);
- __n1 = __n1->_M_next;
- }
- if (__x._M_head._M_next) {
- __n1->_M_next = __x._M_head._M_next;
- __x._M_head._M_next = 0;
- }
-}
-
-template <class _Tp, class _Alloc>
-void slist<_Tp,_Alloc>::sort()
-{
- if (this->_M_head._M_next && this->_M_head._M_next->_M_next) {
- slist __carry;
- slist __counter[64];
- int __fill = 0;
- while (!empty()) {
- __slist_splice_after(&__carry._M_head,
- &this->_M_head, this->_M_head._M_next);
- int __i = 0;
- while (__i < __fill && !__counter[__i].empty()) {
- __counter[__i].merge(__carry);
- __carry.swap(__counter[__i]);
- ++__i;