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;
146 {
return static_cast<_Node*
>(_M_node)->_M_data; }
155 _M_node = _M_node->_M_next;
163 _M_node = _M_node->_M_next;
170 _M_node = _M_node->_M_prev;
178 _M_node = _M_node->_M_prev;
183 operator==(
const _Self& __x)
const
184 {
return _M_node == __x._M_node; }
187 operator!=(
const _Self& __x)
const
188 {
return _M_node != __x._M_node; }
199 template<
typename _Tp>
206 typedef ptrdiff_t difference_type;
208 typedef _Tp value_type;
209 typedef const _Tp* pointer;
210 typedef const _Tp& reference;
220 : _M_node(__x._M_node) { }
226 {
return static_cast<_Node*
>(_M_node)->_M_data; }
235 _M_node = _M_node->_M_next;
243 _M_node = _M_node->_M_next;
250 _M_node = _M_node->_M_prev;
258 _M_node = _M_node->_M_prev;
263 operator==(
const _Self& __x)
const
264 {
return _M_node == __x._M_node; }
267 operator!=(
const _Self& __x)
const
268 {
return _M_node != __x._M_node; }
274 template<
typename _Val>
278 {
return __x._M_node == __y._M_node; }
280 template<
typename _Val>
282 operator!=(
const _List_iterator<_Val>& __x,
283 const _List_const_iterator<_Val>& __y)
284 {
return __x._M_node != __y._M_node; }
288 template<
typename _Tp,
typename _Alloc>
305 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
308 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
311 :
public _Node_alloc_type
316 : _Node_alloc_type(), _M_node()
319 _List_impl(
const _Node_alloc_type& __a)
320 : _Node_alloc_type(__a), _M_node()
323 #if __cplusplus >= 201103L
324 _List_impl(_Node_alloc_type&& __a)
325 : _Node_alloc_type(
std::move(__a)), _M_node()
334 {
return _M_impl._Node_alloc_type::allocate(1); }
338 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
341 typedef _Alloc allocator_type;
344 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
345 {
return *
static_cast<_Node_alloc_type*
>(&_M_impl); }
347 const _Node_alloc_type&
348 _M_get_Node_allocator()
const _GLIBCXX_NOEXCEPT
349 {
return *
static_cast<const _Node_alloc_type*
>(&_M_impl); }
352 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
353 {
return _Tp_alloc_type(_M_get_Node_allocator()); }
356 get_allocator()
const _GLIBCXX_NOEXCEPT
357 {
return allocator_type(_M_get_Node_allocator()); }
367 #if __cplusplus >= 201103L
369 : _M_impl(
std::move(__x._M_get_Node_allocator()))
372 __detail::_List_node_base::swap(_M_impl._M_node, __x._M_impl._M_node);
386 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
387 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
437 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
441 typedef typename _Alloc::value_type _Alloc_value_type;
442 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
443 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
446 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
447 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
450 typedef _Tp value_type;
451 typedef typename _Tp_alloc_type::pointer pointer;
452 typedef typename _Tp_alloc_type::const_pointer const_pointer;
453 typedef typename _Tp_alloc_type::reference reference;
454 typedef typename _Tp_alloc_type::const_reference const_reference;
459 typedef size_t size_type;
460 typedef ptrdiff_t difference_type;
461 typedef _Alloc allocator_type;
468 using _Base::_M_impl;
469 using _Base::_M_put_node;
470 using _Base::_M_get_node;
471 using _Base::_M_get_Tp_allocator;
472 using _Base::_M_get_Node_allocator;
480 #if __cplusplus < 201103L
484 _Node* __p = this->_M_get_node();
487 _M_get_Tp_allocator().construct
493 __throw_exception_again;
498 template<
typename... _Args>
502 _Node* __p = this->_M_get_node();
505 _M_get_Node_allocator().construct(__p,
506 std::forward<_Args>(__args)...);
511 __throw_exception_again;
531 list(
const allocator_type& __a)
532 : _Base(_Node_alloc_type(__a)) { }
534 #if __cplusplus >= 201103L
545 { _M_default_initialize(__n); }
555 list(size_type __n,
const value_type& __value,
556 const allocator_type& __a = allocator_type())
557 : _Base(_Node_alloc_type(__a))
558 { _M_fill_initialize(__n, __value); }
569 list(size_type __n,
const value_type& __value = value_type(),
570 const allocator_type& __a = allocator_type())
571 : _Base(_Node_alloc_type(__a))
572 { _M_fill_initialize(__n, __value); }
583 : _Base(__x._M_get_Node_allocator())
584 { _M_initialize_dispatch(__x.
begin(), __x.
end(), __false_type()); }
586 #if __cplusplus >= 201103L
605 list(initializer_list<value_type> __l,
606 const allocator_type& __a = allocator_type())
607 : _Base(_Node_alloc_type(__a))
608 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
621 #if __cplusplus >= 201103L
622 template<
typename _InputIterator,
623 typename = std::_RequireInputIter<_InputIterator>>
624 list(_InputIterator __first, _InputIterator __last,
625 const allocator_type& __a = allocator_type())
626 : _Base(_Node_alloc_type(__a))
627 { _M_initialize_dispatch(__first, __last, __false_type()); }
629 template<
typename _InputIterator>
630 list(_InputIterator __first, _InputIterator __last,
631 const allocator_type& __a = allocator_type())
632 : _Base(_Node_alloc_type(__a))
635 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
636 _M_initialize_dispatch(__first, __last, _Integral());
658 #if __cplusplus >= 201103L
686 this->
assign(__l.begin(), __l.end());
702 assign(size_type __n,
const value_type& __val)
703 { _M_fill_assign(__n, __val); }
717 #if __cplusplus >= 201103L
718 template<
typename _InputIterator,
719 typename = std::_RequireInputIter<_InputIterator>>
721 assign(_InputIterator __first, _InputIterator __last)
722 { _M_assign_dispatch(__first, __last, __false_type()); }
724 template<
typename _InputIterator>
726 assign(_InputIterator __first, _InputIterator __last)
729 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
730 _M_assign_dispatch(__first, __last, _Integral());
734 #if __cplusplus >= 201103L
744 { this->
assign(__l.begin(), __l.end()); }
750 {
return _Base::get_allocator(); }
759 {
return iterator(this->_M_impl._M_node._M_next); }
768 {
return const_iterator(this->_M_impl._M_node._M_next); }
777 {
return iterator(&this->_M_impl._M_node); }
785 end() const _GLIBCXX_NOEXCEPT
786 {
return const_iterator(&this->_M_impl._M_node); }
795 {
return reverse_iterator(
end()); }
802 const_reverse_iterator
804 {
return const_reverse_iterator(
end()); }
813 {
return reverse_iterator(
begin()); }
820 const_reverse_iterator
822 {
return const_reverse_iterator(
begin()); }
824 #if __cplusplus >= 201103L
832 {
return const_iterator(this->_M_impl._M_node._M_next); }
841 {
return const_iterator(&this->_M_impl._M_node); }
848 const_reverse_iterator
850 {
return const_reverse_iterator(
end()); }
857 const_reverse_iterator
859 {
return const_reverse_iterator(
begin()); }
869 {
return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
879 {
return _M_get_Node_allocator().max_size(); }
881 #if __cplusplus >= 201103L
892 resize(size_type __new_size);
905 resize(size_type __new_size,
const value_type& __x);
918 resize(size_type __new_size, value_type __x = value_type());
945 iterator __tmp =
end();
957 const_iterator __tmp =
end();
975 { this->_M_insert(
begin(), __x); }
977 #if __cplusplus >= 201103L
982 template<
typename... _Args>
984 emplace_front(_Args&&... __args)
985 { this->_M_insert(
begin(), std::forward<_Args>(__args)...); }
1002 { this->_M_erase(
begin()); }
1016 { this->_M_insert(
end(), __x); }
1018 #if __cplusplus >= 201103L
1023 template<
typename... _Args>
1025 emplace_back(_Args&&... __args)
1026 { this->_M_insert(
end(), std::forward<_Args>(__args)...); }
1042 { this->_M_erase(iterator(this->_M_impl._M_node._M_prev)); }
1044 #if __cplusplus >= 201103L
1057 template<
typename... _Args>
1059 emplace(iterator __position, _Args&&... __args);
1074 insert(iterator __position,
const value_type& __x);
1076 #if __cplusplus >= 201103L
1089 insert(iterator __position, value_type&& __x)
1106 insert(iterator __p, initializer_list<value_type> __l)
1107 { this->
insert(__p, __l.begin(), __l.end()); }
1123 insert(iterator __position, size_type __n,
const value_type& __x)
1126 splice(__position, __tmp);
1142 #if __cplusplus >= 201103L
1143 template<
typename _InputIterator,
1144 typename = std::_RequireInputIter<_InputIterator>>
1146 template<
typename _InputIterator>
1149 insert(iterator __position, _InputIterator __first,
1150 _InputIterator __last)
1153 splice(__position, __tmp);
1172 erase(iterator __position);
1193 erase(iterator __first, iterator __last)
1195 while (__first != __last)
1196 __first =
erase(__first);
1212 __detail::_List_node_base::swap(this->_M_impl._M_node,
1213 __x._M_impl._M_node);
1217 std::__alloc_swap<typename _Base::_Node_alloc_type>::
1218 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1247 #if __cplusplus >= 201103L
1255 _M_check_equal_allocators(__x);
1257 this->_M_transfer(__position, __x.
begin(), __x.
end());
1261 #if __cplusplus >= 201103L
1277 #if __cplusplus >= 201103L
1280 splice(iterator __position,
list& __x, iterator __i)
1285 if (__position == __i || __position == __j)
1289 _M_check_equal_allocators(__x);
1291 this->_M_transfer(__position, __i, __j);
1294 #if __cplusplus >= 201103L
1296 splice(iterator __position,
list& __x, iterator __i)
1313 #if __cplusplus >= 201103L
1317 splice(iterator __position,
list& __x, iterator __first,
1321 if (__first != __last)
1324 _M_check_equal_allocators(__x);
1326 this->_M_transfer(__position, __first, __last);
1330 #if __cplusplus >= 201103L
1332 splice(iterator __position,
list& __x, iterator __first, iterator __last)
1348 remove(
const _Tp& __value);
1361 template<
typename _Predicate>
1390 template<
typename _BinaryPredicate>
1392 unique(_BinaryPredicate);
1403 #if __cplusplus >= 201103L
1428 #if __cplusplus >= 201103L
1429 template<
typename _StrictWeakOrdering>
1431 merge(
list&& __x, _StrictWeakOrdering __comp);
1433 template<
typename _StrictWeakOrdering>
1435 merge(
list& __x, _StrictWeakOrdering __comp)
1438 template<
typename _StrictWeakOrdering>
1440 merge(
list& __x, _StrictWeakOrdering __comp);
1450 { this->_M_impl._M_node._M_reverse(); }
1467 template<
typename _StrictWeakOrdering>
1469 sort(_StrictWeakOrdering);
1478 template<
typename _Integer>
1480 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1481 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1484 template<
typename _InputIterator>
1486 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1489 for (; __first != __last; ++__first)
1490 #
if __cplusplus >= 201103L
1491 emplace_back(*__first);
1500 _M_fill_initialize(size_type __n,
const value_type& __x)
1506 #if __cplusplus >= 201103L
1509 _M_default_initialize(size_type __n)
1517 _M_default_append(size_type __n);
1526 template<
typename _Integer>
1528 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1529 { _M_fill_assign(__n, __val); }
1532 template<
typename _InputIterator>
1534 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1540 _M_fill_assign(size_type __n,
const value_type& __val);
1545 _M_transfer(iterator __position, iterator __first, iterator __last)
1546 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
1549 #if __cplusplus < 201103L
1551 _M_insert(iterator __position,
const value_type& __x)
1554 __tmp->_M_hook(__position._M_node);
1557 template<
typename... _Args>
1559 _M_insert(iterator __position, _Args&&... __args)
1562 __tmp->_M_hook(__position._M_node);
1568 _M_erase(iterator __position)
1570 __position._M_node->_M_unhook();
1571 _Node* __n =
static_cast<_Node*
>(__position._M_node);
1572 #if __cplusplus >= 201103L
1573 _M_get_Node_allocator().destroy(__n);
1582 _M_check_equal_allocators(
list& __x)
1584 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1585 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1586 __throw_runtime_error(__N(
"list::_M_check_equal_allocators"));
1600 template<
typename _Tp,
typename _Alloc>
1605 const_iterator __end1 = __x.
end();
1606 const_iterator __end2 = __y.
end();
1608 const_iterator __i1 = __x.
begin();
1609 const_iterator __i2 = __y.
begin();
1610 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1615 return __i1 == __end1 && __i2 == __end2;
1629 template<
typename _Tp,
typename _Alloc>
1633 __y.begin(), __y.end()); }
1636 template<
typename _Tp,
typename _Alloc>
1639 {
return !(__x == __y); }
1642 template<
typename _Tp,
typename _Alloc>
1645 {
return __y < __x; }
1648 template<
typename _Tp,
typename _Alloc>
1651 {
return !(__y < __x); }
1654 template<
typename _Tp,
typename _Alloc>
1657 {
return !(__x < __y); }
1660 template<
typename _Tp,
typename _Alloc>
1665 _GLIBCXX_END_NAMESPACE_CONTAINER
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void splice(iterator __position, list &&__x, iterator __i)
Insert element from another list.
See bits/stl_deque.h's _Deque_base for an explanation.
void insert(iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the list.
const_iterator cbegin() const noexcept
Common part of a node in the list.
list(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a list from an initializer_list.
size_type size() const noexcept
list(const allocator_type &__a)
Creates a list with no elements.
void reverse() noexcept
Reverse the elements in list.
void merge(list &&__x)
Merge sorted lists.
const_reverse_iterator rbegin() const noexcept
void swap(list &__x)
Swaps data with another list.
_Node * _M_create_node(_Args &&...__args)
reverse_iterator rend() noexcept
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void sort()
Sort the elements.
void push_back(const value_type &__x)
Add data to the end of the list.
list(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a list from a range.
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
list & operator=(const list &__x)
List assignment operator.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a list.
const_reference front() const
void unique()
Remove consecutive duplicate elements.
list(size_type __n)
Creates a list with default constructed elements.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
const_iterator cend() const noexcept
_Tp _M_data
< User's data.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
const_iterator begin() const noexcept
iterator insert(iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
bool operator>=(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string doesn't precede string.
An actual node in the list.
list(const list &__x)
List copy constructor.
void splice(iterator __position, list &&__x, iterator __first, iterator __last)
Insert range from another list.
void pop_front()
Removes first element.
iterator begin() noexcept
list & operator=(list &&__x)
List move assignment operator.
ISO C++ entities toplevel namespace is std.
void assign(size_type __n, const value_type &__val)
Assigns a given value to a list.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
void splice(iterator __position, list &&__x)
Insert contents of another list.
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
bool empty() const noexcept
list(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a list with copies of an exemplar element.
iterator erase(iterator __position)
Remove element at given position.
iterator insert(iterator __position, value_type &&__x)
Inserts given rvalue into list before specified iterator.
const_reverse_iterator crbegin() const noexcept
iterator emplace(iterator __position, _Args &&...__args)
Constructs object in list before specified iterator.
list(list &&__x) noexcept
List move constructor.
const_reverse_iterator crend() const noexcept
reverse_iterator rbegin() noexcept
void insert(iterator __p, initializer_list< value_type > __l)
Inserts the contents of an initializer_list into list before specified iterator.
const_reference back() const
list()
Default constructor creates no elements.
void push_front(const value_type &__x)
Add data to the front of the list.
iterator erase(iterator __first, iterator __last)
Remove a range of elements.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
void swap(_Tp &, _Tp &) noexcept(__and_< is_nothrow_move_constructible< _Tp >, is_nothrow_move_assignable< _Tp >>::value)
Swaps two values.
const_reverse_iterator rend() const noexcept
size_type max_size() const noexcept
void insert(iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the list.
void assign(initializer_list< value_type > __l)
Assigns an initializer_list to a list.
void remove_if(_Predicate)
Remove all elements satisfying a predicate.
list & operator=(initializer_list< value_type > __l)
List initializer list assignment operator.
void pop_back()
Removes last element.
const_iterator end() const noexcept
bool operator>(const basic_string< _CharT, _Traits, _Alloc > &__lhs, const basic_string< _CharT, _Traits, _Alloc > &__rhs)
Test if string follows string.
Bidirectional iterators support a superset of forward iterator operations.