61 #ifdef __GXX_EXPERIMENTAL_CXX0X__
65 namespace std _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_VERSION
91 _M_reverse() _GLIBCXX_USE_NOEXCEPT;
97 _M_unhook() _GLIBCXX_USE_NOEXCEPT;
100 _GLIBCXX_END_NAMESPACE_VERSION
103 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
106 template<
typename _Tp>
112 #ifdef __GXX_EXPERIMENTAL_CXX0X__
113 template<
typename... _Args>
115 : __detail::_List_node_base(),
_M_data(std::
forward<_Args>(__args)...)
125 template<
typename _Tp>
131 typedef ptrdiff_t difference_type;
133 typedef _Tp value_type;
134 typedef _Tp* pointer;
135 typedef _Tp& reference;
147 {
return static_cast<_Node*
>(_M_node)->_M_data; }
156 _M_node = _M_node->_M_next;
164 _M_node = _M_node->_M_next;
171 _M_node = _M_node->_M_prev;
179 _M_node = _M_node->_M_prev;
184 operator==(
const _Self& __x)
const
185 {
return _M_node == __x._M_node; }
188 operator!=(
const _Self& __x)
const
189 {
return _M_node != __x._M_node; }
200 template<
typename _Tp>
207 typedef ptrdiff_t difference_type;
209 typedef _Tp value_type;
210 typedef const _Tp* pointer;
211 typedef const _Tp& reference;
221 : _M_node(__x._M_node) { }
227 {
return static_cast<_Node*
>(_M_node)->_M_data; }
236 _M_node = _M_node->_M_next;
244 _M_node = _M_node->_M_next;
251 _M_node = _M_node->_M_prev;
259 _M_node = _M_node->_M_prev;
264 operator==(
const _Self& __x)
const
265 {
return _M_node == __x._M_node; }
268 operator!=(
const _Self& __x)
const
269 {
return _M_node != __x._M_node; }
275 template<
typename _Val>
279 {
return __x._M_node == __y._M_node; }
281 template<
typename _Val>
283 operator!=(
const _List_iterator<_Val>& __x,
284 const _List_const_iterator<_Val>& __y)
285 {
return __x._M_node != __y._M_node; }
289 template<
typename _Tp,
typename _Alloc>
306 typedef typename _Alloc::template rebind<_List_node<_Tp> >::other
309 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
312 :
public _Node_alloc_type
317 : _Node_alloc_type(), _M_node()
320 _List_impl(
const _Node_alloc_type& __a)
321 : _Node_alloc_type(__a), _M_node()
324 #ifdef __GXX_EXPERIMENTAL_CXX0X__
325 _List_impl(_Node_alloc_type&& __a)
326 : _Node_alloc_type(std::move(__a)), _M_node()
335 {
return _M_impl._Node_alloc_type::allocate(1); }
339 { _M_impl._Node_alloc_type::deallocate(__p, 1); }
342 typedef _Alloc allocator_type;
345 _M_get_Node_allocator() _GLIBCXX_NOEXCEPT
346 {
return *
static_cast<_Node_alloc_type*
>(&_M_impl); }
348 const _Node_alloc_type&
349 _M_get_Node_allocator()
const _GLIBCXX_NOEXCEPT
350 {
return *
static_cast<const _Node_alloc_type*
>(&_M_impl); }
353 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
354 {
return _Tp_alloc_type(_M_get_Node_allocator()); }
357 get_allocator()
const _GLIBCXX_NOEXCEPT
358 {
return allocator_type(_M_get_Node_allocator()); }
368 #ifdef __GXX_EXPERIMENTAL_CXX0X__
370 : _M_impl(std::move(__x._M_get_Node_allocator()))
373 __detail::_List_node_base::swap(_M_impl._M_node, __x._M_impl._M_node);
387 this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
388 this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
435 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
439 typedef typename _Alloc::value_type _Alloc_value_type;
440 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
441 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
444 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
445 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
448 typedef _Tp value_type;
449 typedef typename _Tp_alloc_type::pointer pointer;
450 typedef typename _Tp_alloc_type::const_pointer const_pointer;
451 typedef typename _Tp_alloc_type::reference reference;
452 typedef typename _Tp_alloc_type::const_reference const_reference;
457 typedef size_t size_type;
458 typedef ptrdiff_t difference_type;
459 typedef _Alloc allocator_type;
466 using _Base::_M_impl;
467 using _Base::_M_put_node;
468 using _Base::_M_get_node;
469 using _Base::_M_get_Tp_allocator;
470 using _Base::_M_get_Node_allocator;
478 #ifndef __GXX_EXPERIMENTAL_CXX0X__
482 _Node* __p = this->_M_get_node();
485 _M_get_Tp_allocator().construct
491 __throw_exception_again;
496 template<
typename... _Args>
500 _Node* __p = this->_M_get_node();
503 _M_get_Node_allocator().construct(__p,
504 std::forward<_Args>(__args)...);
509 __throw_exception_again;
529 list(
const allocator_type& __a)
530 :
_Base(_Node_alloc_type(__a)) { }
532 #ifdef __GXX_EXPERIMENTAL_CXX0X__
543 { _M_default_initialize(__n); }
553 list(size_type __n,
const value_type& __value,
554 const allocator_type& __a = allocator_type())
555 :
_Base(_Node_alloc_type(__a))
556 { _M_fill_initialize(__n, __value); }
567 list(size_type __n,
const value_type& __value = value_type(),
568 const allocator_type& __a = allocator_type())
569 : _Base(_Node_alloc_type(__a))
570 { _M_fill_initialize(__n, __value); }
581 :
_Base(__x._M_get_Node_allocator())
582 { _M_initialize_dispatch(__x.
begin(), __x.
end(), __false_type()); }
584 #ifdef __GXX_EXPERIMENTAL_CXX0X__
593 :
_Base(std::move(__x)) { }
604 const allocator_type& __a = allocator_type())
605 :
_Base(_Node_alloc_type(__a))
606 { _M_initialize_dispatch(__l.begin(), __l.end(), __false_type()); }
619 template<
typename _InputIterator>
620 list(_InputIterator __first, _InputIterator __last,
621 const allocator_type& __a = allocator_type())
622 :
_Base(_Node_alloc_type(__a))
625 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
626 _M_initialize_dispatch(__first, __last, _Integral());
647 #ifdef __GXX_EXPERIMENTAL_CXX0X__
675 this->
assign(__l.begin(), __l.end());
691 assign(size_type __n,
const value_type& __val)
692 { _M_fill_assign(__n, __val); }
706 template<
typename _InputIterator>
708 assign(_InputIterator __first, _InputIterator __last)
711 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
712 _M_assign_dispatch(__first, __last, _Integral());
715 #ifdef __GXX_EXPERIMENTAL_CXX0X__
725 { this->
assign(__l.begin(), __l.end()); }
731 {
return _Base::get_allocator(); }
740 {
return iterator(this->_M_impl._M_node._M_next); }
758 {
return iterator(&this->_M_impl._M_node); }
766 end() const _GLIBCXX_NOEXCEPT
783 const_reverse_iterator
801 const_reverse_iterator
805 #ifdef __GXX_EXPERIMENTAL_CXX0X__
829 const_reverse_iterator
838 const_reverse_iterator
850 {
return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
860 {
return _M_get_Node_allocator().max_size(); }
862 #ifdef __GXX_EXPERIMENTAL_CXX0X__
873 resize(size_type __new_size);
886 resize(size_type __new_size,
const value_type& __x);
899 resize(size_type __new_size, value_type __x = value_type());
956 { this->_M_insert(
begin(), __x); }
958 #ifdef __GXX_EXPERIMENTAL_CXX0X__
961 { this->_M_insert(
begin(), std::move(__x)); }
963 template<
typename... _Args>
965 emplace_front(_Args&&... __args)
966 { this->_M_insert(
begin(), std::forward<_Args>(__args)...); }
983 { this->_M_erase(
begin()); }
997 { this->_M_insert(
end(), __x); }
999 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1002 { this->_M_insert(
end(), std::move(__x)); }
1004 template<
typename... _Args>
1006 emplace_back(_Args&&... __args)
1007 { this->_M_insert(
end(), std::forward<_Args>(__args)...); }
1023 { this->_M_erase(
iterator(this->_M_impl._M_node._M_prev)); }
1025 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1038 template<
typename... _Args>
1057 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1071 {
return emplace(__position, std::move(__x)); }
1088 { this->
insert(__p, __l.begin(), __l.end()); }
1107 splice(__position, __tmp);
1123 template<
typename _InputIterator>
1126 _InputIterator __last)
1129 splice(__position, __tmp);
1171 while (__first != __last)
1172 __first =
erase(__first);
1188 __detail::_List_node_base::swap(this->_M_impl._M_node,
1189 __x._M_impl._M_node);
1193 std::__alloc_swap<typename _Base::_Node_alloc_type>::
1194 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator());
1223 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1231 _M_check_equal_allocators(__x);
1233 this->_M_transfer(__position, __x.
begin(), __x.
end());
1237 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1240 {
splice(__position, std::move(__x)); }
1253 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1261 if (__position == __i || __position == __j)
1265 _M_check_equal_allocators(__x);
1267 this->_M_transfer(__position, __i, __j);
1270 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1273 {
splice(__position, std::move(__x), __i); }
1289 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1297 if (__first != __last)
1300 _M_check_equal_allocators(__x);
1302 this->_M_transfer(__position, __first, __last);
1306 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1309 {
splice(__position, std::move(__x), __first, __last); }
1324 remove(
const _Tp& __value);
1337 template<
typename _Predicate>
1366 template<
typename _BinaryPredicate>
1368 unique(_BinaryPredicate);
1379 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1385 {
merge(std::move(__x)); }
1404 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1405 template<
typename _StrictWeakOrdering>
1407 merge(
list&& __x, _StrictWeakOrdering __comp);
1409 template<
typename _StrictWeakOrdering>
1411 merge(
list& __x, _StrictWeakOrdering __comp)
1412 {
merge(std::move(__x), __comp); }
1414 template<
typename _StrictWeakOrdering>
1416 merge(
list& __x, _StrictWeakOrdering __comp);
1426 { this->_M_impl._M_node._M_reverse(); }
1443 template<
typename _StrictWeakOrdering>
1445 sort(_StrictWeakOrdering);
1454 template<
typename _Integer>
1456 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1457 { _M_fill_initialize(static_cast<size_type>(__n), __x); }
1460 template<
typename _InputIterator>
1462 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1465 for (; __first != __last; ++__first)
1472 _M_fill_initialize(size_type __n,
const value_type& __x)
1478 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1481 _M_default_initialize(size_type __n)
1489 _M_default_append(size_type __n);
1498 template<
typename _Integer>
1500 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1501 { _M_fill_assign(__n, __val); }
1504 template<
typename _InputIterator>
1506 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1512 _M_fill_assign(size_type __n,
const value_type& __val);
1517 _M_transfer(iterator __position, iterator __first, iterator __last)
1518 { __position._M_node->_M_transfer(__first._M_node, __last._M_node); }
1521 #ifndef __GXX_EXPERIMENTAL_CXX0X__
1523 _M_insert(iterator __position,
const value_type& __x)
1526 __tmp->_M_hook(__position._M_node);
1529 template<
typename... _Args>
1531 _M_insert(iterator __position, _Args&&... __args)
1534 __tmp->_M_hook(__position._M_node);
1540 _M_erase(iterator __position)
1542 __position._M_node->_M_unhook();
1543 _Node* __n =
static_cast<_Node*
>(__position._M_node);
1544 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1545 _M_get_Node_allocator().destroy(__n);
1554 _M_check_equal_allocators(
list& __x)
1556 if (std::__alloc_neq<typename _Base::_Node_alloc_type>::
1557 _S_do_it(_M_get_Node_allocator(), __x._M_get_Node_allocator()))
1558 __throw_runtime_error(__N(
"list::_M_check_equal_allocators"));
1572 template<
typename _Tp,
typename _Alloc>
1577 const_iterator __end1 = __x.
end();
1578 const_iterator __end2 = __y.
end();
1580 const_iterator __i1 = __x.
begin();
1581 const_iterator __i2 = __y.
begin();
1582 while (__i1 != __end1 && __i2 != __end2 && *__i1 == *__i2)
1587 return __i1 == __end1 && __i2 == __end2;
1601 template<
typename _Tp,
typename _Alloc>
1605 __y.begin(), __y.end()); }
1608 template<
typename _Tp,
typename _Alloc>
1611 {
return !(__x == __y); }
1614 template<
typename _Tp,
typename _Alloc>
1617 {
return __y < __x; }
1620 template<
typename _Tp,
typename _Alloc>
1623 {
return !(__y < __x); }
1626 template<
typename _Tp,
typename _Alloc>
1629 {
return !(__x < __y); }
1632 template<
typename _Tp,
typename _Alloc>
1637 _GLIBCXX_END_NAMESPACE_CONTAINER
const_reference front() const
void remove_if(_Predicate)
Remove all elements satisfying a predicate.
void push_front(const value_type &__x)
Add data to the front of the list.
void assign(size_type __n, const value_type &__val)
Assigns a given value to a list.
const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT
const_iterator end() const _GLIBCXX_NOEXCEPT
bool empty() const _GLIBCXX_NOEXCEPT
list(list &&__x) noexcept
List move constructor.
iterator insert(iterator __position, value_type &&__x)
Inserts given rvalue into list before specified iterator.
list & operator=(list &&__x)
List move assignment operator.
void insert(iterator __p, initializer_list< value_type > __l)
Inserts the contents of an initializer_list into list before specified iterator.
Bidirectional iterators support a superset of forward iterator operations.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
list(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a list from a range.
iterator insert(iterator __position, const value_type &__x)
Inserts given value into list before specified iterator.
const_reverse_iterator crend() const noexcept
size_type size() const _GLIBCXX_NOEXCEPT
void insert(iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the list.
const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT
constexpr _Tp && forward(typename std::remove_reference< _Tp >::type &__t) noexcept
Forward an lvalue.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a list.
list(const allocator_type &__a)
Creates a list with no elements.
iterator emplace(iterator __position, _Args &&...__args)
Constructs object in list before specified iterator.
void swap(list &__x)
Swaps data with another list.
_Tp _M_data
< User's data.
const_iterator cbegin() const noexcept
list & operator=(initializer_list< value_type > __l)
List initializer list assignment operator.
void pop_back()
Removes last element.
list(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a list from an initializer_list.
reverse_iterator rend() _GLIBCXX_NOEXCEPT
list(size_type __n)
Creates a list with default constructed elements.
list()
Default constructor creates no elements.
allocator_type get_allocator() const _GLIBCXX_NOEXCEPT
Get a copy of the memory allocation object.
void insert(iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the list.
void reverse() _GLIBCXX_NOEXCEPT
Reverse the elements in list.
void splice(iterator __position, list &&__x, iterator __first, iterator __last)
Insert range from another list.
void assign(initializer_list< value_type > __l)
Assigns an initializer_list to a list.
const_iterator cend() const noexcept
reverse_iterator rbegin() _GLIBCXX_NOEXCEPT
void clear() _GLIBCXX_NOEXCEPT
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void splice(iterator __position, list &&__x)
Insert contents of another list.
An actual node in the list.
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 __first, iterator __last)
Remove a range of elements.
void sort()
Sort the elements.
iterator begin() _GLIBCXX_NOEXCEPT
const_iterator begin() const _GLIBCXX_NOEXCEPT
const_reverse_iterator crbegin() const noexcept
_Node * _M_create_node(_Args &&...__args)
list & operator=(const list &__x)
List assignment operator.
iterator erase(iterator __position)
Remove element at given position.
void unique()
Remove consecutive duplicate elements.
See bits/stl_deque.h's _Deque_base for an explanation.
const_reference back() const
void push_back(const value_type &__x)
Add data to the end of the list.
void splice(iterator __position, list &&__x, iterator __i)
Insert element from another list.
void pop_front()
Removes first element.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
_Tp * __addressof(_Tp &__r) _GLIBCXX_NOEXCEPT
Same as C++11 std::addressof.
Common part of a node in the list.
iterator end() _GLIBCXX_NOEXCEPT
void merge(list &&__x)
Merge sorted lists.
size_type max_size() const _GLIBCXX_NOEXCEPT
void resize(size_type __new_size)
Resizes the list to the specified number of elements.
list(const list &__x)
List copy constructor.