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 _Node* __cur =
static_cast<_Node*
>(_M_impl._M_node._M_next);
70 while (__cur != &_M_impl._M_node)
73 __cur =
static_cast<_Node*
>(__cur->_M_next);
74 #if __cplusplus >= 201103L
75 _M_get_Node_allocator().destroy(__tmp);
83 #if __cplusplus >= 201103L
84 template<
typename _Tp,
typename _Alloc>
85 template<
typename... _Args>
86 typename list<_Tp, _Alloc>::iterator
88 emplace(const_iterator __position, _Args&&... __args)
90 _Node* __tmp = _M_create_node(std::forward<_Args>(__args)...);
91 __tmp->_M_hook(__position._M_const_cast()._M_node);
92 return iterator(__tmp);
96 template<
typename _Tp,
typename _Alloc>
97 typename list<_Tp, _Alloc>::iterator
99 #if __cplusplus >= 201103L
100 insert(const_iterator __position,
const value_type& __x)
102 insert(iterator __position,
const value_type& __x)
105 _Node* __tmp = _M_create_node(__x);
106 __tmp->_M_hook(__position._M_const_cast()._M_node);
107 return iterator(__tmp);
110 #if __cplusplus >= 201103L
111 template<
typename _Tp,
typename _Alloc>
112 typename list<_Tp, _Alloc>::iterator
118 list __tmp(__n, __x, get_allocator());
120 splice(__position, __tmp);
123 return __position._M_const_cast();
126 template<
typename _Tp,
typename _Alloc>
127 template<
typename _InputIterator,
typename>
130 insert(const_iterator __position, _InputIterator __first,
131 _InputIterator __last)
133 list __tmp(__first, __last, get_allocator());
137 splice(__position, __tmp);
140 return __position._M_const_cast();
144 template<
typename _Tp,
typename _Alloc>
145 typename list<_Tp, _Alloc>::iterator
147 #if __cplusplus >= 201103L
154 _M_erase(__position._M_const_cast());
158 #if __cplusplus >= 201103L
159 template<
typename _Tp,
typename _Alloc>
167 for (; __i < __n; ++__i)
174 __throw_exception_again;
178 template<
typename _Tp,
typename _Alloc>
185 for (; __i !=
end() && __len < __new_size; ++__i, ++__len)
187 if (__len == __new_size)
190 _M_default_append(__new_size - __len);
193 template<
typename _Tp,
typename _Alloc>
196 resize(size_type __new_size,
const value_type& __x)
200 for (; __i !=
end() && __len < __new_size; ++__i, ++__len)
202 if (__len == __new_size)
205 insert(
end(), __new_size - __len, __x);
208 template<
typename _Tp,
typename _Alloc>
211 resize(size_type __new_size, value_type __x)
215 for (; __i !=
end() && __len < __new_size; ++__i, ++__len)
217 if (__len == __new_size)
220 insert(
end(), __new_size - __len, __x);
224 template<
typename _Tp,
typename _Alloc>
235 for (; __first1 != __last1 && __first2 != __last2;
236 ++__first1, ++__first2)
237 *__first1 = *__first2;
238 if (__first2 == __last2)
239 erase(__first1, __last1);
241 insert(__last1, __first2, __last2);
246 template<
typename _Tp,
typename _Alloc>
252 for (; __i !=
end() && __n > 0; ++__i, --__n)
255 insert(
end(), __n, __val);
260 template<
typename _Tp,
typename _Alloc>
261 template <
typename _InputIterator>
264 _M_assign_dispatch(_InputIterator __first2, _InputIterator __last2,
267 iterator __first1 =
begin();
268 iterator __last1 =
end();
269 for (; __first1 != __last1 && __first2 != __last2;
270 ++__first1, ++__first2)
271 *__first1 = *__first2;
272 if (__first2 == __last2)
273 erase(__first1, __last1);
275 insert(__last1, __first2, __last2);
278 template<
typename _Tp,
typename _Alloc>
286 while (__first != __last)
290 if (*__first == __value)
302 if (__extra != __last)
306 template<
typename _Tp,
typename _Alloc>
313 if (__first == __last)
316 while (++__next != __last)
318 if (*__first == *__next)
326 template<
typename _Tp,
typename _Alloc>
329 #if __cplusplus >= 201103L
339 _M_check_equal_allocators(__x);
345 while (__first1 != __last1 && __first2 != __last2)
346 if (*__first2 < *__first1)
349 _M_transfer(__first1, __first2, ++__next);
354 if (__first2 != __last2)
355 _M_transfer(__last1, __first2, __last2);
359 template<
typename _Tp,
typename _Alloc>
360 template <
typename _StrictWeakOrdering>
363 #if __cplusplus >= 201103L
364 merge(list&& __x, _StrictWeakOrdering __comp)
366 merge(list& __x, _StrictWeakOrdering __comp)
373 _M_check_equal_allocators(__x);
375 iterator __first1 =
begin();
376 iterator __last1 =
end();
377 iterator __first2 = __x.begin();
378 iterator __last2 = __x.end();
379 while (__first1 != __last1 && __first2 != __last2)
380 if (__comp(*__first2, *__first1))
382 iterator __next = __first2;
383 _M_transfer(__first1, __first2, ++__next);
388 if (__first2 != __last2)
389 _M_transfer(__last1, __first2, __last2);
393 template<
typename _Tp,
typename _Alloc>
399 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
400 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
404 list * __fill = &__tmp[0];
411 for(__counter = &__tmp[0];
412 __counter != __fill && !__counter->
empty();
415 __counter->
merge(__carry);
416 __carry.
swap(*__counter);
418 __carry.
swap(*__counter);
419 if (__counter == __fill)
424 for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
425 __counter->
merge(*(__counter - 1));
426 swap( *(__fill - 1) );
430 template<
typename _Tp,
typename _Alloc>
431 template <
typename _Predicate>
438 while (__first != __last)
442 if (__pred(*__first))
448 template<
typename _Tp,
typename _Alloc>
449 template <
typename _BinaryPredicate>
456 if (__first == __last)
459 while (++__next != __last)
461 if (__binary_pred(*__first, *__next))
469 template<
typename _Tp,
typename _Alloc>
470 template <
typename _StrictWeakOrdering>
473 sort(_StrictWeakOrdering __comp)
476 if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
477 && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
481 list * __fill = &__tmp[0];
488 for(__counter = &__tmp[0];
489 __counter != __fill && !__counter->
empty();
492 __counter->
merge(__carry, __comp);
493 __carry.
swap(*__counter);
495 __carry.
swap(*__counter);
496 if (__counter == __fill)
501 for (__counter = &__tmp[1]; __counter != __fill; ++__counter)
502 __counter->
merge(*(__counter - 1), __comp);
507 _GLIBCXX_END_NAMESPACE_CONTAINER
void sort()
Sort the elements.
void remove_if(_Predicate)
Remove all elements satisfying a predicate.
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another 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.
void merge(list &&__x)
Merge sorted lists.
void remove(const _Tp &__value)
Remove all elements equal to value.
list & operator=(const list &__x)
List assignment operator.
iterator emplace(const_iterator __position, _Args &&...__args)
Constructs object in list before specified iterator.
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. ...
void swap(function< _Res(_Args...)> &__x, function< _Res(_Args...)> &__y)
Swap the targets of two polymorphic function object wrappers.
iterator begin() noexcept
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
void unique()
Remove consecutive duplicate elements.
void swap(list &__x)
Swaps data with another list.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.