59 namespace std _GLIBCXX_VISIBILITY(default)
61 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
63 template<
typename _Tp,
typename _Alloc>
65 _List_base<_Tp, _Alloc>::
66 _M_clear() _GLIBCXX_NOEXCEPT
68 typedef _List_node<_Tp> _Node;
69 __detail::_List_node_base* __cur = _M_impl._M_node._M_next;
70 while (__cur != &_M_impl._M_node)
72 _Node* __tmp =
static_cast<_Node*
>(__cur);
73 __cur = __tmp->_M_next;
74 _Tp* __val = __tmp->_M_valptr();
75 #if __cplusplus >= 201103L 76 _Node_alloc_traits::destroy(_M_get_Node_allocator(), __val);
78 _Tp_alloc_type(_M_get_Node_allocator()).destroy(__val);
84 #if __cplusplus >= 201103L 85 template<
typename _Tp,
typename _Alloc>
86 template<
typename... _Args>
87 typename list<_Tp, _Alloc>::iterator
91 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
92 __tmp->_M_hook(__position._M_const_cast()._M_node);
98 template<
typename _Tp,
typename _Alloc>
101 #if __cplusplus >= 201103L 104 insert(
iterator __position,
const value_type& __x)
107 _Node* __tmp = _M_create_node(__x);
108 __tmp->_M_hook(__position._M_const_cast()._M_node);
109 this->_M_inc_size(1);
113 #if __cplusplus >= 201103L 114 template<
typename _Tp,
typename _Alloc>
121 list __tmp(__n, __x, get_allocator());
123 splice(__position, __tmp);
126 return __position._M_const_cast();
129 template<
typename _Tp,
typename _Alloc>
130 template<
typename _InputIterator,
typename>
134 _InputIterator __last)
136 list __tmp(__first, __last, get_allocator());
140 splice(__position, __tmp);
143 return __position._M_const_cast();
147 template<
typename _Tp,
typename _Alloc>
150 #if __cplusplus >= 201103L 157 _M_erase(__position._M_const_cast());
172 template<
typename _Tp,
typename _Alloc>
178 #if _GLIBCXX_USE_CXX11_ABI 179 const size_type __len = size();
180 if (__new_size < __len)
182 if (__new_size <= __len / 2)
190 ptrdiff_t __num_erase = __len - __new_size;
200 for (__i =
begin(); __i !=
end() && __len < __new_size; ++__i, ++__len)
207 #if __cplusplus >= 201103L 208 template<
typename _Tp,
typename _Alloc>
216 for (; __i < __n; ++__i)
223 __throw_exception_again;
227 template<
typename _Tp,
typename _Alloc>
234 _M_default_append(__new_size);
239 template<
typename _Tp,
typename _Alloc>
242 resize(size_type __new_size,
const value_type& __x)
246 insert(
end(), __new_size, __x);
251 template<
typename _Tp,
typename _Alloc>
254 resize(size_type __new_size, value_type __x)
258 insert(
end(), __new_size, __x);
260 erase(__i._M_const_cast(),
end());
264 template<
typename _Tp,
typename _Alloc>
271 #if __cplusplus >= 201103L 272 if (_Node_alloc_traits::_S_propagate_on_copy_assign())
274 auto& __this_alloc = this->_M_get_Node_allocator();
275 auto& __that_alloc = __x._M_get_Node_allocator();
276 if (!_Node_alloc_traits::_S_always_equal()
277 && __this_alloc != __that_alloc)
282 std::__alloc_on_copy(__this_alloc, __that_alloc);
285 _M_assign_dispatch(__x.
begin(), __x.
end(), __false_type());
290 template<
typename _Tp,
typename _Alloc>
296 for (; __i !=
end() && __n > 0; ++__i, --__n)
299 insert(
end(), __n, __val);
304 template<
typename _Tp,
typename _Alloc>
305 template <
typename _InputIterator>
313 for (; __first1 != __last1 && __first2 != __last2;
314 ++__first1, ++__first2)
315 *__first1 = *__first2;
316 if (__first2 == __last2)
317 erase(__first1, __last1);
319 insert(__last1, __first2, __last2);
322 template<
typename _Tp,
typename _Alloc>
330 while (__first != __last)
334 if (*__first == __value)
346 if (__extra != __last)
350 template<
typename _Tp,
typename _Alloc>
357 if (__first == __last)
360 while (++__next != __last)
362 if (*__first == *__next)
370 template<
typename _Tp,
typename _Alloc>
373 #if __cplusplus >= 201103L 383 _M_check_equal_allocators(__x);
389 const size_t __orig_size = __x.
size();
391 while (__first1 != __last1 && __first2 != __last2)
392 if (*__first2 < *__first1)
395 _M_transfer(__first1, __first2, ++__next);
400 if (__first2 != __last2)
401 _M_transfer(__last1, __first2, __last2);
403 this->_M_inc_size(__x._M_get_size());
409 this->_M_inc_size(__orig_size - __dist);
410 __x._M_set_size(__dist);
411 __throw_exception_again;
416 template<
typename _Tp,
typename _Alloc>
417 template <
typename _StrictWeakOrdering>
420 #if __cplusplus >= 201103L 421 merge(
list&& __x, _StrictWeakOrdering __comp)
423 merge(
list& __x, _StrictWeakOrdering __comp)
430 _M_check_equal_allocators(__x);
436 const size_t __orig_size = __x.
size();
439 while (__first1 != __last1 && __first2 != __last2)
440 if (__comp(*__first2, *__first1))
443 _M_transfer(__first1, __first2, ++__next);
448 if (__first2 != __last2)
449 _M_transfer(__last1, __first2, __last2);
451 this->_M_inc_size(__x._M_get_size());
457 this->_M_inc_size(__orig_size - __dist);
458 __x._M_set_size(__dist);
459 __throw_exception_again;
464 template<
typename _Tp,
typename _Alloc>
470 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
471 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
475 list * __fill = __tmp;
483 for(__counter = __tmp;
484 __counter != __fill && !__counter->
empty();
487 __counter->
merge(__carry);
488 __carry.
swap(*__counter);
490 __carry.
swap(*__counter);
491 if (__counter == __fill)
496 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
497 __counter->
merge(*(__counter - 1));
498 swap( *(__fill - 1) );
502 this->splice(this->
end(), __carry);
503 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
504 this->splice(this->
end(), __tmp[__i]);
505 __throw_exception_again;
510 template<
typename _Tp,
typename _Alloc>
511 template <
typename _Predicate>
518 while (__first != __last)
522 if (__pred(*__first))
528 template<
typename _Tp,
typename _Alloc>
529 template <
typename _BinaryPredicate>
536 if (__first == __last)
539 while (++__next != __last)
541 if (__binary_pred(*__first, *__next))
549 template<
typename _Tp,
typename _Alloc>
550 template <
typename _StrictWeakOrdering>
553 sort(_StrictWeakOrdering __comp)
556 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
557 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
561 list * __fill = __tmp;
569 for(__counter = __tmp;
570 __counter != __fill && !__counter->
empty();
573 __counter->
merge(__carry, __comp);
574 __carry.
swap(*__counter);
576 __carry.
swap(*__counter);
577 if (__counter == __fill)
582 for (__counter = __tmp + 1; __counter != __fill; ++__counter)
583 __counter->
merge(*(__counter - 1), __comp);
588 this->splice(this->
end(), __carry);
589 for (
int __i = 0; __i <
sizeof(__tmp)/
sizeof(__tmp[0]); ++__i)
590 this->splice(this->
end(), __tmp[__i]);
591 __throw_exception_again;
596 _GLIBCXX_END_NAMESPACE_CONTAINER
iterator begin() noexcept
void swap(list &__x) noexcept
Swaps data with another list.
void unique()
Remove consecutive duplicate elements.
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
bool empty() const noexcept
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
ISO C++ entities toplevel namespace is std.
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another list.
void merge(list &&__x)
Merge sorted lists.
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
list & operator=(const list &__x)
List assignment operator.
_GLIBCXX17_CONSTEXPR iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
void remove(const _Tp &__value)
Remove all elements equal to value.
_GLIBCXX17_CONSTEXPR void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void remove_if(_Predicate)
Remove all elements satisfying a predicate.
void sort()
Sort the elements.
iterator emplace(const_iterator __position, _Args &&...__args)
Constructs object in list before specified iterator.
size_type size() const noexcept