60 #if __cplusplus >= 201103L
61 #include <initializer_list>
64 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_VERSION
90 _M_reverse() _GLIBCXX_USE_NOEXCEPT;
96 _M_unhook() _GLIBCXX_USE_NOEXCEPT;
99 _GLIBCXX_END_NAMESPACE_VERSION
102 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
105 template<
typename _Tp>
111 #if __cplusplus >= 201103L
112 template<
typename... _Args>
114 : __detail::_List_node_base(), _M_data(
std::
forward<_Args>(__args)...)
124 template<
typename _Tp>
130 typedef ptrdiff_t difference_type;
132 typedef _Tp value_type;
133 typedef _Tp* pointer;
134 typedef _Tp& reference;
144 _M_const_cast()
const _GLIBCXX_NOEXCEPT
149 operator*()
const _GLIBCXX_NOEXCEPT
150 {
return static_cast<_Node*
>(_M_node)->_M_data; }
153 operator->()
const _GLIBCXX_NOEXCEPT
157 operator++() _GLIBCXX_NOEXCEPT
159 _M_node = _M_node->_M_next;
164 operator++(
int) _GLIBCXX_NOEXCEPT
167 _M_node = _M_node->_M_next;
172 operator--() _GLIBCXX_NOEXCEPT
174 _M_node = _M_node->_M_prev;
179 operator--(
int) _GLIBCXX_NOEXCEPT
182 _M_node = _M_node->_M_prev;
187 operator==(
const _Self& __x)
const _GLIBCXX_NOEXCEPT
188 {
return _M_node == __x._M_node; }
191 operator!=(
const _Self& __x)
const _GLIBCXX_NOEXCEPT
192 {
return _M_node != __x._M_node; }
203 template<
typename _Tp>
210 typedef ptrdiff_t difference_type;
212 typedef _Tp value_type;
213 typedef const _Tp* pointer;
214 typedef const _Tp& reference;
225 : _M_node(__x._M_node) { }
228 _M_const_cast()
const _GLIBCXX_NOEXCEPT
229 {
return iterator(const_cast<__detail::_List_node_base*>(_M_node)); }
234 operator*()
const _GLIBCXX_NOEXCEPT
235 {
return static_cast<_Node*
>(_M_node)->_M_data; }
238 operator->()
const _GLIBCXX_NOEXCEPT
242 operator++() _GLIBCXX_NOEXCEPT
244 _M_node = _M_node->_M_next;
249 operator++(
int) _GLIBCXX_NOEXCEPT
252 _M_node = _M_node->_M_next;
257 operator--() _GLIBCXX_NOEXCEPT
259 _M_node = _M_node->_M_prev;
264 operator--(
int) _GLIBCXX_NOEXCEPT
267 _M_node = _M_node->_M_prev;
272 operator==(
const _Self& __x)
const _GLIBCXX_NOEXCEPT
273 {
return _M_node == __x._M_node; }
276 operator!=(
const _Self& __x)
const _GLIBCXX_NOEXCEPT
277 {
return _M_node != __x._M_node; }
283 template<
typename _Val>
287 {
return __x._M_node == __y._M_node; }
289 template<
typename _Val>
291 operator!=(
const _List_iterator<_Val>& __x,
292 const _List_const_iterator<_Val>& __y) _GLIBCXX_NOEXCEPT
293 {
return __x._M_node != __y._M_node; }
297 template<
typename _Tp,
typename _Alloc>
314 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
317 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
320 :
public _Node_alloc_type
325 : _Node_alloc_type(), _M_node()
328 _List_impl(
const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT
329 : _Node_alloc_type(__a), _M_node()
332 #if __cplusplus >= 201103L
333 _List_impl(_Node_alloc_type&& __a) _GLIBCXX_NOEXCEPT
334 : _Node_alloc_type(
std::move(__a)), _M_node()
343 {
return _M_impl._Node_alloc_type::allocate(1); }
347 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
350 typedef _Alloc allocator_type;
353 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
354 {
return *
static_cast<_Node_alloc_type*
>(&_M_impl); }
356 const _Node_alloc_type&
357 _M_get_Node_allocator()
const _GLIBCXX_NOEXCEPT
358 {
return *
static_cast<const _Node_alloc_type*
>(&_M_impl); }
361 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
362 {
return _Tp_alloc_type(_M_get_Node_allocator()); }
365 get_allocator()
const _GLIBCXX_NOEXCEPT
366 {
return allocator_type(_M_get_Node_allocator()); }
372 _List_base(
const _Node_alloc_type& __a) _GLIBCXX_NOEXCEPT
376 #if __cplusplus >= 201103L
378 : _M_impl(
std::move(__x._M_get_Node_allocator()))
381 __detail::_List_node_base::swap(_M_impl._M_node, __x._M_impl._M_node);
390 _M_clear() _GLIBCXX_NOEXCEPT;
393 _M_init() _GLIBCXX_NOEXCEPT
395 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
396 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
446 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
450 typedef typename _Alloc::value_type _Alloc_value_type;
451 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
452 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
455 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
456 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
459 typedef _Tp value_type;
460 typedef typename _Tp_alloc_type::pointer pointer;
461 typedef typename _Tp_alloc_type::const_pointer const_pointer;
462 typedef typename _Tp_alloc_type::reference reference;
463 typedef typename _Tp_alloc_type::const_reference const_reference;
468 typedef size_t size_type;
469 typedef ptrdiff_t difference_type;
470 typedef _Alloc allocator_type;
477 using _Base::_M_impl;
478 using _Base::_M_put_node;
479 using _Base::_M_get_node;
480 using _Base::_M_get_Tp_allocator;
481 using _Base::_M_get_Node_allocator;
489 #if __cplusplus < 201103L
493 _Node* __p = this->_M_get_node();
496 _M_get_Tp_allocator().construct
502 __throw_exception_again;
507 template<
typename... _Args>
511 _Node* __p = this->_M_get_node();
514 _M_get_Node_allocator().construct(__p,
515 std::forward<_Args>(__args)...);
520 __throw_exception_again;
534 #if __cplusplus >= 201103L
535 noexcept(is_nothrow_default_constructible<_Node_alloc_type>::value)
544 list(
const allocator_type& __a) _GLIBCXX_NOEXCEPT
545 : _Base(_Node_alloc_type(__a)) { }
547 #if __cplusplus >= 201103L
558 { _M_default_initialize(__n); }
568 list(size_type __n,
const value_type& __value,
569 const allocator_type& __a = allocator_type())
570 : _Base(_Node_alloc_type(__a))
571 { _M_fill_initialize(__n, __value); }
582 list(size_type __n,
const value_type& __value = value_type(),
583 const allocator_type& __a = allocator_type())
584 : _Base(_Node_alloc_type(__a))
585 { _M_fill_initialize(__n, __value); }
596 : _Base(__x._M_get_Node_allocator())
597 { _M_initialize_dispatch(__x.
begin(), __x.
end(), __false_type()); }
599 #if __cplusplus >= 201103L
618 list(initializer_list<value_type> __l,
619 const allocator_type& __a = allocator_type())
620 : _Base(_Node_alloc_type(__a))
621 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
634 #if __cplusplus >= 201103L
635 template<
typename _InputIterator,
636 typename = std::_RequireInputIter<_InputIterator>>
637 list(_InputIterator __first, _InputIterator __last,
638 const allocator_type& __a = allocator_type())
639 : _Base(_Node_alloc_type(__a))
640 { _M_initialize_dispatch(__first, __last, __false_type()); }
642 template<
typename _InputIterator>
643 list(_InputIterator __first, _InputIterator __last,
644 const allocator_type& __a = allocator_type())
645 : _Base(_Node_alloc_type(__a))
648 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
649 _M_initialize_dispatch(__first, __last, _Integral());
671 #if __cplusplus >= 201103L
699 this->
assign(__l.begin(), __l.end());
715 assign(size_type __n,
const value_type& __val)
716 { _M_fill_assign(__n, __val); }
730 #if __cplusplus >= 201103L
731 template<
typename _InputIterator,
732 typename = std::_RequireInputIter<_InputIterator>>
734 assign(_InputIterator __first, _InputIterator __last)
735 { _M_assign_dispatch(__first, __last, __false_type()); }
737 template<
typename _InputIterator>
739 assign(_InputIterator __first, _InputIterator __last)
742 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
743 _M_assign_dispatch(__first, __last, _Integral());
747 #if __cplusplus >= 201103L
757 { this->
assign(__l.begin(), __l.end()); }
763 {
return _Base::get_allocator(); }
772 {
return iterator(this->_M_impl._M_node._M_next); }
781 {
return const_iterator(this->_M_impl._M_node._M_next); }
790 {
return iterator(&this->_M_impl._M_node); }
798 end() const _GLIBCXX_NOEXCEPT
799 {
return const_iterator(&this->_M_impl._M_node); }
808 {
return reverse_iterator(
end()); }
815 const_reverse_iterator
817 {
return const_reverse_iterator(
end()); }
826 {
return reverse_iterator(
begin()); }
833 const_reverse_iterator
835 {
return const_reverse_iterator(
begin()); }
837 #if __cplusplus >= 201103L
845 {
return const_iterator(this->_M_impl._M_node._M_next); }
854 {
return const_iterator(&this->_M_impl._M_node); }
861 const_reverse_iterator
863 {
return const_reverse_iterator(
end()); }
870 const_reverse_iterator
872 {
return const_reverse_iterator(
begin()); }
882 {
return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
892 {
return _M_get_Node_allocator().max_size(); }
894 #if __cplusplus >= 201103L
905 resize(size_type __new_size);
918 resize(size_type __new_size,
const value_type& __x);
931 resize(size_type __new_size, value_type __x = value_type());
958 iterator __tmp =
end();
970 const_iterator __tmp =
end();
988 { this->_M_insert(
begin(), __x); }
990 #if __cplusplus >= 201103L
995 template<
typename... _Args>
997 emplace_front(_Args&&... __args)
998 { this->_M_insert(
begin(), std::forward<_Args>(__args)...); }
1015 { this->_M_erase(
begin()); }
1029 { this->_M_insert(
end(), __x); }
1031 #if __cplusplus >= 201103L
1036 template<
typename... _Args>
1038 emplace_back(_Args&&... __args)
1039 { this->_M_insert(
end(), std::forward<_Args>(__args)...); }
1055 { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
1057 #if __cplusplus >= 201103L
1070 template<
typename... _Args>
1072 emplace(const_iterator __position, _Args&&... __args);
1086 insert(const_iterator __position,
const value_type& __x);
1100 insert(iterator __position,
const value_type& __x);
1103 #if __cplusplus >= 201103L
1116 insert(const_iterator __position, value_type&& __x)
1135 insert(const_iterator __p, initializer_list<value_type> __l)
1136 {
return this->
insert(__p, __l.begin(), __l.end()); }
1139 #if __cplusplus >= 201103L
1155 insert(const_iterator __position, size_type __n,
const value_type& __x);
1170 insert(iterator __position, size_type __n,
const value_type& __x)
1173 splice(__position, __tmp);
1177 #if __cplusplus >= 201103L
1193 template<
typename _InputIterator,
1194 typename = std::_RequireInputIter<_InputIterator>>
1196 insert(const_iterator __position, _InputIterator __first,
1197 _InputIterator __last);
1212 template<
typename _InputIterator>
1214 insert(iterator __position, _InputIterator __first,
1215 _InputIterator __last)
1218 splice(__position, __tmp);
1238 #if __cplusplus >= 201103L
1239 erase(const_iterator __position) noexcept;
1241 erase(iterator __position);
1263 #if __cplusplus >= 201103L
1264 erase(const_iterator __first, const_iterator __last) noexcept
1266 erase(iterator __first, iterator __last)
1269 while (__first != __last)
1270 __first =
erase(__first);
1271 return __last._M_const_cast();
1286 __detail::_List_node_base::swap(this->_M_impl._M_node,
1287 __x._M_impl._M_node);
1291 std::__alloc_swap<typename _Base::_Node_alloc_type>::
1292 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1321 #if __cplusplus >= 201103L
1329 _M_check_equal_allocators(__x);
1331 this->_M_transfer(__position._M_const_cast(),
1336 #if __cplusplus >= 201103L
1338 splice(const_iterator __position,
list& __x) noexcept
1342 #if __cplusplus >= 201103L
1354 splice(const_iterator __position,
list&& __x, const_iterator __i) noexcept
1366 splice(iterator __position,
list& __x, iterator __i)
1369 iterator __j = __i._M_const_cast();
1371 if (__position == __i || __position == __j)
1375 _M_check_equal_allocators(__x);
1377 this->_M_transfer(__position._M_const_cast(),
1378 __i._M_const_cast(), __j);
1381 #if __cplusplus >= 201103L
1393 splice(const_iterator __position,
list& __x, const_iterator __i) noexcept
1397 #if __cplusplus >= 201103L
1412 splice(const_iterator __position,
list&& __x, const_iterator __first,
1413 const_iterator __last) noexcept
1428 splice(iterator __position,
list& __x, iterator __first,
1432 if (__first != __last)
1435 _M_check_equal_allocators(__x);
1437 this->_M_transfer(__position._M_const_cast(),
1438 __first._M_const_cast(),
1439 __last._M_const_cast());
1443 #if __cplusplus >= 201103L
1458 splice(const_iterator __position,
list& __x, const_iterator __first,
1459 const_iterator __last) noexcept
1475 remove(
const _Tp& __value);
1488 template<
typename _Predicate>
1517 template<
typename _BinaryPredicate>
1519 unique(_BinaryPredicate);
1530 #if __cplusplus >= 201103L
1555 #if __cplusplus >= 201103L
1556 template<
typename _StrictWeakOrdering>
1558 merge(
list&& __x, _StrictWeakOrdering __comp);
1560 template<
typename _StrictWeakOrdering>
1562 merge(
list& __x, _StrictWeakOrdering __comp)
1565 template<
typename _StrictWeakOrdering>
1567 merge(
list& __x, _StrictWeakOrdering __comp);
1577 { this->_M_impl._M_node._M_reverse(); }
1594 template<
typename _StrictWeakOrdering>
1596 sort(_StrictWeakOrdering);
1605 template<
typename _Integer>
1607 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1608 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1611 template<
typename _InputIterator>
1613 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1616 for (; __first != __last; ++__first)
1617 #
if __cplusplus >= 201103L
1618 emplace_back(*__first);
1627 _M_fill_initialize(size_type __n,
const value_type& __x)
1633 #if __cplusplus >= 201103L
1636 _M_default_initialize(size_type __n)
1644 _M_default_append(size_type __n);
1653 template<
typename _Integer>
1655 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1656 { _M_fill_assign(__n, __val); }
1659 template<
typename _InputIterator>
1661 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1667 _M_fill_assign(size_type __n,
const value_type& __val);
1672 _M_transfer(iterator __position, iterator __first, iterator __last)
1673 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
1676 #if __cplusplus < 201103L
1678 _M_insert(iterator __position,
const value_type& __x)
1681 __tmp->_M_hook(__position._M_node);
1684 template<
typename... _Args>
1686 _M_insert(iterator __position, _Args&&... __args)
1689 __tmp->_M_hook(__position._M_node);
1695 _M_erase(iterator __position) _GLIBCXX_NOEXCEPT
1697 __position._M_node->_M_unhook();
1698 _Node* __n =
static_cast<_Node*
>(__position._M_node);
1699 #if __cplusplus >= 201103L
1700 _M_get_Node_allocator().destroy(__n);
1709 _M_check_equal_allocators(
list& __x) _GLIBCXX_NOEXCEPT
1711 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1712 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1727 template<
typename _Tp,
typename _Alloc>
1732 const_iterator __end1 = __x.
end();
1733 const_iterator __end2 = __y.
end();
1735 const_iterator __i1 = __x.
begin();
1736 const_iterator __i2 = __y.
begin();
1737 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1742 return __i1 == __end1 && __i2 == __end2;
1756 template<
typename _Tp,
typename _Alloc>
1760 __y.begin(), __y.end()); }
1763 template<
typename _Tp,
typename _Alloc>
1766 {
return !(__x == __y); }
1769 template<
typename _Tp,
typename _Alloc>
1772 {
return __y < __x; }
1775 template<
typename _Tp,
typename _Alloc>
1778 {
return !(__y < __x); }
1781 template<
typename _Tp,
typename _Alloc>
1784 {
return !(__x < __y); }
1787 template<
typename _Tp,
typename _Alloc>
1792 _GLIBCXX_END_NAMESPACE_CONTAINER
void push_front(const value_type &__x)
Add data to the front of the list.
list(size_type __n)
Creates a list with default constructed elements.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
iterator erase(const_iterator __position) noexcept
Remove element at given position.
const_iterator cbegin() const noexcept
void splice(const_iterator __position, list &__x, const_iterator __first, const_iterator __last) noexcept
Insert range from another list.
void splice(const_iterator __position, list &&__x, const_iterator __i) noexcept
Insert element from another list.
size_type size() const noexcept
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
list(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a list with copies of an exemplar element.
reverse_iterator rend() noexcept
reverse_iterator rbegin() noexcept
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
const_reverse_iterator rend() const noexcept
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
list(list &&__x) noexcept
List move constructor.
void swap(list &__x)
Swaps data with another list.
const_reference back() const noexcept
_Node * _M_create_node(_Args &&...__args)
const_iterator begin() const noexcept
void splice(const_iterator __position, list &__x, const_iterator __i) noexcept
Insert element from another list.
list() noexcept(is_nothrow_default_constructible< _Node_alloc_type >::value)
Creates a list with no elements.
void reverse() noexcept
Reverse the elements in list.
An actual node in the list.
list(const allocator_type &__a) noexcept
Creates a list with no elements.
reference back() noexcept
list(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a list from a range.
void unique()
Remove consecutive duplicate elements.
void assign(initializer_list< value_type > __l)
Assigns an initializer_list to a list.
const_reference front() const noexcept
list & operator=(initializer_list< value_type > __l)
List initializer list assignment operator.
bool empty() const noexcept
const_reverse_iterator rbegin() const noexcept
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
list(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a list from an initializer_list.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a list.
void sort()
Sort the elements.
ISO C++ entities toplevel namespace is std.
See bits/stl_deque.h's _Deque_base for an explanation.
iterator insert(const_iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
iterator erase(const_iterator __first, const_iterator __last) noexcept
Remove a range of elements.
void splice(const_iterator __position, list &&__x, const_iterator __first, const_iterator __last) noexcept
Insert range from another list.
const_iterator end() const noexcept
void remove_if(_Predicate)
Remove all elements satisfying a predicate.
_Tp _M_data
< User's data.
void push_back(const value_type &__x)
Add data to the end of the list.
reference front() noexcept
void assign(size_type __n, const value_type &__val)
Assigns a given value to a list.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
const_reverse_iterator crbegin() const noexcept
list & operator=(list &&__x)
List move assignment operator.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
Bidirectional iterators support a superset of forward iterator operations.
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into list before specified iterator.
const_reverse_iterator crend() const noexcept
void splice(const_iterator __position, list &&__x) noexcept
Insert contents of another list.
list & operator=(const list &__x)
List assignment operator.
void pop_front() noexcept
Removes first element.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
const_iterator cend() const noexcept
list(const list &__x)
List copy constructor.
iterator insert(const_iterator __p, initializer_list< value_type > __l)
Inserts the contents of an initializer_list into list before specified const_iterator.
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
Common part of a node in the list.
size_type max_size() const noexcept
iterator emplace(const_iterator __position, _Args &&...__args)
Constructs object in list before specified iterator.
void pop_back() noexcept
Removes last element.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
iterator begin() noexcept
void merge(list &&__x)
Merge sorted lists.