59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
62_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
64 template<
typename _Tp,
typename _Alloc>
66 _List_base<_Tp, _Alloc>::
67 _M_clear() _GLIBCXX_NOEXCEPT
69 typedef _List_node<_Tp> _Node;
70 __detail::_List_node_base* __cur = _M_impl._M_node._M_next;
71 while (__cur != &_M_impl._M_node)
73 _Node* __tmp =
static_cast<_Node*
>(__cur);
74 __cur = __tmp->_M_next;
75 _Tp* __val = __tmp->_M_valptr();
76#if __cplusplus >= 201103L
77 _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
79 _Tp_alloc_type(_M_get_Node_allocator()).destroy(__val);
85#if __cplusplus >= 201103L
86 template<
typename _Tp,
typename _Alloc>
87 template<
typename... _Args>
88 typename list<_Tp, _Alloc>::iterator
92 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
93 __tmp->_M_hook(__position._M_const_cast()._M_node);
99 template<
typename _Tp,
typename _Alloc>
102#if __cplusplus >= 201103L
105 insert(
iterator __position,
const value_type& __x)
108 _Node* __tmp = _M_create_node(__x);
109 __tmp->_M_hook(__position._M_const_cast()._M_node);
110 this->_M_inc_size(1);
114#if __cplusplus >= 201103L
115 template<
typename _Tp,
typename _Alloc>
122 list __tmp(__n, __x, get_allocator());
124 splice(__position, __tmp);
127 return __position._M_const_cast();
130 template<
typename _Tp,
typename _Alloc>
131 template<
typename _InputIterator,
typename>
135 _InputIterator __last)
137 list __tmp(__first, __last, get_allocator());
141 splice(__position, __tmp);
144 return __position._M_const_cast();
148 template<
typename _Tp,
typename _Alloc>
151#if __cplusplus >= 201103L
158 _M_erase(__position._M_const_cast());
173 template<
typename _Tp,
typename _Alloc>
179#if _GLIBCXX_USE_CXX11_ABI
180 const size_type __len = size();
181 if (__new_size < __len)
183 if (__new_size <= __len / 2)
191 ptrdiff_t __num_erase = __len - __new_size;
201 for (__i =
begin(); __i !=
end() && __len < __new_size; ++__i, ++__len)
208#if __cplusplus >= 201103L
209 template<
typename _Tp,
typename _Alloc>
212 _M_default_append(size_type __n)
217 for (; __i < __n; ++__i)
224 __throw_exception_again;
228 template<
typename _Tp,
typename _Alloc>
231 resize(size_type __new_size)
235 _M_default_append(__new_size);
240 template<
typename _Tp,
typename _Alloc>
243 resize(size_type __new_size,
const value_type& __x)
247 insert(
end(), __new_size, __x);
252 template<
typename _Tp,
typename _Alloc>
255 resize(size_type __new_size, value_type __x)
257 const_iterator __i = _M_resize_pos(__new_size);
259 insert(
end(), __new_size, __x);
261 erase(__i._M_const_cast(),
end());
265 template<
typename _Tp,
typename _Alloc>
272#if __cplusplus >= 201103L
273 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
275 auto& __this_alloc = this->_M_get_Node_allocator();
276 auto& __that_alloc = __x._M_get_Node_allocator();
277 if (!_Node_alloc_traits::_S_always_equal()
278 && __this_alloc != __that_alloc)
283 std::__alloc_on_copy(__this_alloc, __that_alloc);
286 _M_assign_dispatch(__x.
begin(), __x.
end(), __false_type());
291 template<
typename _Tp,
typename _Alloc>
297 for (; __i !=
end() && __n > 0; ++__i, --__n)
300 insert(
end(), __n, __val);
305 template<
typename _Tp,
typename _Alloc>
306 template <
typename _InputIterator>
309 _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
312 iterator __first1 =
begin();
313 iterator __last1 =
end();
314 for (; __first1 != __last1 && __first2 != __last2;
315 ++__first1, (void)++__first2)
316 *__first1 = *__first2;
317 if (__first2 == __last2)
318 erase(__first1, __last1);
320 insert(__last1, __first2, __last2);
323#if __cplusplus > 201703L
324# define _GLIBCXX20_ONLY(__expr) __expr
326# define _GLIBCXX20_ONLY(__expr)
329 template<
typename _Tp,
typename _Alloc>
330 typename list<_Tp, _Alloc>::__remove_return_type
332 remove(
const value_type& __value)
334 size_type __removed __attribute__((__unused__)) = 0;
338 while (__first != __last)
342 if (*__first == __value)
350 _GLIBCXX20_ONLY( __removed++ );
357 if (__extra != __last)
360 _GLIBCXX20_ONLY( __removed++ );
362 return _GLIBCXX20_ONLY( __removed );
365 template<
typename _Tp,
typename _Alloc>
366 typename list<_Tp, _Alloc>::__remove_return_type
372 if (__first == __last)
373 return _GLIBCXX20_ONLY( 0 );
374 size_type __removed __attribute__((__unused__)) = 0;
376 while (++__next != __last)
378 if (*__first == *__next)
381 _GLIBCXX20_ONLY( __removed++ );
387 return _GLIBCXX20_ONLY( __removed );
390 template<
typename _Tp,
typename _Alloc>
393#if __cplusplus >= 201103L
403 _M_check_equal_allocators(__x);
409#if _GLIBCXX_USE_CXX11_ABI
410 const size_t __orig_size = __x.
size();
413 while (__first1 != __last1 && __first2 != __last2)
414 if (*__first2 < *__first1)
417 _M_transfer(__first1, __first2, ++__next);
422 if (__first2 != __last2)
423 _M_transfer(__last1, __first2, __last2);
425 this->_M_inc_size(__x._M_get_size());
427#if _GLIBCXX_USE_CXX11_ABI
432 this->_M_inc_size(__orig_size - __dist);
433 __x._M_set_size(__dist);
434 __throw_exception_again;
440 template<
typename _Tp,
typename _Alloc>
441 template <
typename _StrictWeakOrdering>
444#if __cplusplus >= 201103L
445 merge(
list&& __x, _StrictWeakOrdering __comp)
447 merge(
list& __x, _StrictWeakOrdering __comp)
454 _M_check_equal_allocators(__x);
460 const size_t __orig_size = __x.
size();
463 while (__first1 != __last1 && __first2 != __last2)
464 if (__comp(*__first2, *__first1))
467 _M_transfer(__first1, __first2, ++__next);
472 if (__first2 != __last2)
473 _M_transfer(__last1, __first2, __last2);
475 this->_M_inc_size(__x._M_get_size());
481 this->_M_inc_size(__orig_size - __dist);
482 __x._M_set_size(__dist);
483 __throw_exception_again;
488 template<
typename _Tp,
typename _Alloc>
494 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
495 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
499 list * __fill = __tmp;
507 for(__counter = __tmp;
508 __counter != __fill && !__counter->
empty();
511 __counter->
merge(__carry);
512 __carry.
swap(*__counter);
514 __carry.
swap(*__counter);
515 if (__counter == __fill)
520 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
521 __counter->
merge(*(__counter - 1));
522 swap( *(__fill - 1) );
526 this->splice(this->
end(), __carry);
527 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
528 this->splice(this->
end(), __tmp[__i]);
529 __throw_exception_again;
534 template<
typename _Tp,
typename _Alloc>
535 template <
typename _Predicate>
536 typename list<_Tp, _Alloc>::__remove_return_type
540 size_type __removed __attribute__((__unused__)) = 0;
543 while (__first != __last)
547 if (__pred(*__first))
550 _GLIBCXX20_ONLY( __removed++ );
554 return _GLIBCXX20_ONLY( __removed );
557 template<
typename _Tp,
typename _Alloc>
558 template <
typename _BinaryPredicate>
559 typename list<_Tp, _Alloc>::__remove_return_type
561 unique(_BinaryPredicate __binary_pred)
565 if (__first == __last)
566 return _GLIBCXX20_ONLY(0);
567 size_type __removed __attribute__((__unused__)) = 0;
569 while (++__next != __last)
571 if (__binary_pred(*__first, *__next))
574 _GLIBCXX20_ONLY( __removed++ );
580 return _GLIBCXX20_ONLY( __removed );
583#undef _GLIBCXX20_ONLY
585 template<
typename _Tp,
typename _Alloc>
586 template <
typename _StrictWeakOrdering>
589 sort(_StrictWeakOrdering __comp)
592 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
593 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
597 list * __fill = __tmp;
605 for(__counter = __tmp;
606 __counter != __fill && !__counter->
empty();
609 __counter->
merge(__carry, __comp);
610 __carry.
swap(*__counter);
612 __carry.
swap(*__counter);
613 if (__counter == __fill)
618 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
619 __counter->
merge(*(__counter - 1), __comp);
624 this->splice(this->
end(), __carry);
625 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
626 this->splice(this->
end(), __tmp[__i]);
627 __throw_exception_again;
632_GLIBCXX_END_NAMESPACE_CONTAINER
633_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
An actual node in the list.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
void sort()
Sort the elements.
iterator begin() noexcept
iterator emplace(const_iterator __position, _Args &&... __args)
Constructs object in list before specified iterator.
list & operator=(const list &__x)
List assignment operator.
__remove_return_type unique()
Remove consecutive duplicate elements.
size_type size() const noexcept
void merge(list &&__x)
Merge sorted lists.
__remove_return_type remove(const _Tp &__value)
Remove all elements equal to value.
__remove_return_type remove_if(_Predicate)
Remove all elements satisfying a predicate.
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another list.
bool empty() const noexcept
void swap(list &__x) noexcept
Swaps data with another list.