30#ifndef _FORWARD_LIST_H
31#define _FORWARD_LIST_H 1
33#pragma GCC system_header
44namespace std _GLIBCXX_VISIBILITY(default)
46_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
66 __begin->_M_next = __end->_M_next;
67 __end->_M_next = _M_next;
76 _M_reverse_after()
noexcept
97 template<
typename _Tp>
103 __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
107 {
return _M_storage._M_ptr(); }
110 _M_valptr()
const noexcept
111 {
return _M_storage._M_ptr(); }
119 template<
typename _Tp>
125 typedef _Tp value_type;
126 typedef _Tp* pointer;
127 typedef _Tp& reference;
139 operator*()
const noexcept
140 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
143 operator->()
const noexcept
144 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
147 operator++()
noexcept
149 _M_node = _M_node->_M_next;
154 operator++(
int)
noexcept
157 _M_node = _M_node->_M_next;
162 operator==(
const _Self& __x)
const noexcept
163 {
return _M_node == __x._M_node; }
166 operator!=(
const _Self& __x)
const noexcept
167 {
return _M_node != __x._M_node; }
170 _M_next()
const noexcept
186 template<
typename _Tp>
193 typedef _Tp value_type;
194 typedef const _Tp* pointer;
195 typedef const _Tp& reference;
207 : _M_node(__iter._M_node) { }
210 operator*()
const noexcept
211 {
return *
static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
214 operator->()
const noexcept
215 {
return static_cast<_Node*
>(this->_M_node)->_M_valptr(); }
218 operator++()
noexcept
220 _M_node = _M_node->_M_next;
225 operator++(
int)
noexcept
228 _M_node = _M_node->_M_next;
233 operator==(
const _Self& __x)
const noexcept
234 {
return _M_node == __x._M_node; }
237 operator!=(
const _Self& __x)
const noexcept
238 {
return _M_node != __x._M_node; }
241 _M_next()
const noexcept
255 template<
typename _Tp>
259 {
return __x._M_node ==
__y._M_node; }
264 template<
typename _Tp>
268 {
return __x._M_node !=
__y._M_node; }
273 template<
typename _Tp,
typename _Alloc>
281 struct _Fwd_list_impl
282 :
public _Node_alloc_type
287 : _Node_alloc_type(), _M_head()
290 _Fwd_list_impl(
const _Node_alloc_type& __a)
291 : _Node_alloc_type(__a), _M_head()
294 _Fwd_list_impl(_Node_alloc_type&& __a)
295 : _Node_alloc_type(std::move(__a)), _M_head()
299 _Fwd_list_impl _M_impl;
307 _M_get_Node_allocator()
noexcept
308 {
return this->_M_impl; }
310 const _Node_alloc_type&
311 _M_get_Node_allocator()
const noexcept
312 {
return this->_M_impl; }
318 : _M_impl(std::move(__a)) { }
323 : _M_impl(std::move(
__lst._M_get_Node_allocator()))
325 this->_M_impl._M_head._M_next =
__lst._M_impl._M_head._M_next;
326 __lst._M_impl._M_head._M_next = 0;
330 { _M_erase_after(&_M_impl._M_head, 0); }
341 template<
typename...
_Args>
351 _Alloc_traits::construct(__a,
__node->_M_valptr(),
356 this->_M_put_node(
__node);
357 __throw_exception_again;
362 template<
typename...
_Args>
367 _M_put_node(
_Node* __p)
408 template<
typename _Tp,
typename _Alloc = allocator<_Tp> >
415 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
416 typedef typename _Base::_Node_alloc_type _Node_alloc_type;
417 typedef typename _Base::_Node_alloc_traits _Node_alloc_traits;
422 typedef _Tp value_type;
424 typedef typename _Alloc_traits::const_pointer const_pointer;
425 typedef value_type& reference;
426 typedef const value_type& const_reference;
430 typedef std::size_t size_type;
432 typedef _Alloc allocator_type;
469 noexcept(_Node_alloc_traits::_S_always_equal())
475 std::__make_move_if_noexcept_iterator(
__list.begin()),
476 std::__make_move_if_noexcept_iterator(
__list.end()));
490 { _M_default_initialize(__n); }
502 const _Alloc&
__al = _Alloc())
504 { _M_fill_initialize(__n, __value); }
519 const _Alloc&
__al = _Alloc())
521 { _M_range_initialize(__first, __last); }
529 :
_Base(_Node_alloc_traits::_S_select_on_copy(
530 __list._M_get_Node_allocator()))
554 const _Alloc&
__al = _Alloc())
556 { _M_range_initialize(
__il.begin(),
__il.end()); }
586 noexcept(_Node_alloc_traits::_S_nothrow_move())
589 _Node_alloc_traits::_S_propagate_on_move_assign()
590 || _Node_alloc_traits::_S_always_equal();
660 {
return allocator_type(this->_M_get_Node_allocator()); }
670 {
return iterator(&this->_M_impl._M_head); }
687 {
return iterator(this->_M_impl._M_head._M_next); }
749 {
return this->_M_impl._M_head._M_next == 0; }
756 {
return _Node_alloc_traits::max_size(this->_M_get_Node_allocator()); }
795 template<
typename...
_Args>
820 { this->_M_insert_after(
cbefore_begin(), std::move(__val)); }
836 { this->_M_erase_after(&this->_M_impl._M_head); }
851 template<
typename...
_Args>
878 {
return iterator(this->_M_insert_after(
__pos, std::move(__val))); }
896 insert_after(const_iterator __pos, size_type __n,
const _Tp& __val);
913 template<
typename _InputIterator,
917 _InputIterator __first, _InputIterator __last);
983 (__last._M_node))); }
998 std::swap(this->_M_impl._M_head._M_next,
999 __list._M_impl._M_head._M_next);
1000 _Node_alloc_traits::_S_on_swap(this->_M_get_Node_allocator(),
1001 __list._M_get_Node_allocator());
1031 resize(size_type
__sz,
const value_type& __val);
1043 { this->_M_erase_after(&this->_M_impl._M_head, 0); }
1081 const_iterator __i)
noexcept;
1085 const_iterator __i)
noexcept
1125 remove(
const _Tp& __val);
1138 template<
typename _Pred>
1168 template<
typename _BinPred>
1200 template<
typename _Comp>
1204 template<
typename _Comp>
1225 template<
typename _Comp>
1236 { this->_M_impl._M_head._M_reverse_after(); }
1240 template<
typename _InputIterator>
1247 _M_fill_initialize(size_type __n,
const value_type& __value);
1251 _M_splice_after(const_iterator
__pos, const_iterator
__before,
1252 const_iterator __last);
1256 _M_default_initialize(size_type __n);
1260 _M_default_insert_after(const_iterator
__pos, size_type __n);
1267 this->_M_impl._M_head._M_next =
__list._M_impl._M_head._M_next;
1268 __list._M_impl._M_head._M_next =
nullptr;
1269 std::__alloc_on_move(this->_M_get_Node_allocator(),
1270 __list._M_get_Node_allocator());
1277 if (__list._M_get_Node_allocator() == this->_M_get_Node_allocator())
1282 this->
assign(std::__make_move_if_noexcept_iterator(__list.begin()),
1283 std::__make_move_if_noexcept_iterator(__list.end()));
1288 template<
typename _InputIterator>
1290 _M_assign(_InputIterator __first, _InputIterator __last,
true_type)
1293 auto __curr =
begin();
1295 while (__curr != __end && __first != __last)
1302 if (__first != __last)
1304 else if (__curr != __end)
1310 template<
typename _InputIterator>
1312 _M_assign(_InputIterator __first, _InputIterator __last,
false_type)
1320 _M_assign_n(size_type __n,
const _Tp& __val,
true_type)
1323 auto __curr =
begin();
1325 while (__curr != __end && __n > 0)
1334 else if (__curr != __end)
1340 _M_assign_n(size_type __n,
const _Tp& __val,
false_type)
1357 template<
typename _Tp,
typename _Alloc>
1359 operator==(
const forward_list<_Tp, _Alloc>& __lx,
1360 const forward_list<_Tp, _Alloc>& __ly);
1374 template<
typename _Tp,
typename _Alloc>
1378 {
return std::lexicographical_compare(
__lx.cbegin(),
__lx.cend(),
1382 template<
typename _Tp,
typename _Alloc>
1389 template<
typename _Tp,
typename _Alloc>
1396 template<
typename _Tp,
typename _Alloc>
1403 template<
typename _Tp,
typename _Alloc>
1410 template<
typename _Tp,
typename _Alloc>
1414 noexcept(
noexcept(
__lx.swap(
__ly)))
1417_GLIBCXX_END_NAMESPACE_CONTAINER
integral_constant< bool, true > true_type
The type used as a compile-time boolean with true value.
integral_constant< bool, false > false_type
The type used as a compile-time boolean with false value.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
ISO C++ entities toplevel namespace is std.
A helper basic node class for forward_list. This is just a linked list with nothing inside it....
A helper node class for forward_list. This is just a linked list with uninitialized storage for a dat...
A forward_list::iterator.
A forward_list::const_iterator.
Base class for forward_list.
A standard container with linear time access to elements, and fixed time insertion/deletion at any po...
void merge(forward_list &__list)
Insert range from another forward_list.
iterator begin() noexcept
void unique()
Remove consecutive duplicate elements.
const_iterator before_begin() const noexcept
void merge(forward_list &__list, _Comp __comp)
Insert range from another forward_list.
void reverse() noexcept
Reverse the elements in list.
~forward_list() noexcept
The forward_list dtor.
iterator erase_after(const_iterator __pos)
Removes the element pointed to by the iterator following pos.
forward_list(forward_list &&__list, const _Alloc &__al) noexcept(_Node_alloc_traits::_S_always_equal())
Move constructor with allocator argument.
void swap(forward_list &__list) noexcept
Swaps data with another forward_list.
const_reference front() const
forward_list(const forward_list &__list, const _Alloc &__al)
Copy constructor with allocator argument.
void merge(forward_list &&__list)
Merge sorted lists.
forward_list(const _Alloc &__al) noexcept
Creates a forward_list with no elements.
void sort()
Sort the elements of the list.
iterator before_begin() noexcept
forward_list(forward_list &&__list) noexcept
The forward_list move constructor.
iterator emplace_after(const_iterator __pos, _Args &&... __args)
Constructs object in forward_list after the specified iterator.
forward_list(const forward_list &__list)
The forward_list copy constructor.
iterator insert_after(const_iterator __pos, const _Tp &__val)
Inserts given value into forward_list after specified iterator.
forward_list & operator=(forward_list &&__list) noexcept(_Node_alloc_traits::_S_nothrow_move())
The forward_list move assignment operator.
void resize(size_type __sz)
Resizes the forward_list to the specified number of elements.
forward_list & operator=(const forward_list &__list)
The forward_list assignment operator.
forward_list(size_type __n, const _Tp &__value, const _Alloc &__al=_Alloc())
Creates a forward_list with copies of an exemplar element.
void assign(size_type __n, const _Tp &__val)
Assigns a given value to a forward_list.
const_iterator begin() const noexcept
void splice_after(const_iterator __pos, forward_list &&__list) noexcept
Insert contents of another forward_list.
const_iterator cbefore_begin() const noexcept
forward_list & operator=(std::initializer_list< _Tp > __il)
The forward_list initializer list assignment operator.
forward_list(std::initializer_list< _Tp > __il, const _Alloc &__al=_Alloc())
Builds a forward_list from an initializer_list.
forward_list(size_type __n, const _Alloc &__al=_Alloc())
Creates a forward_list with default constructed elements.
iterator insert_after(const_iterator __pos, std::initializer_list< _Tp > __il)
Inserts the contents of an initializer_list into forward_list after the specified iterator.
const_iterator end() const noexcept
void splice_after(const_iterator __pos, forward_list &&, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
iterator erase_after(const_iterator __pos, const_iterator __last)
Remove a range of elements.
void clear() noexcept
Erases all the elements.
const_iterator cend() const noexcept
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a forward_list.
bool empty() const noexcept
void remove_if(_Pred __pred)
Remove all elements satisfying a predicate.
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
void emplace_front(_Args &&... __args)
Constructs object in forward_list at the front of the list.
void push_front(const _Tp &__val)
Add data to the front of the forward_list.
forward_list(_InputIterator __first, _InputIterator __last, const _Alloc &__al=_Alloc())
Builds a forward_list from a range.
void splice_after(const_iterator __pos, forward_list &, const_iterator __before, const_iterator __last) noexcept
Insert range from another forward_list.
const_iterator cbegin() const noexcept
void pop_front()
Removes first element.
forward_list() noexcept(is_nothrow_default_constructible< _Node_alloc_type >::value)
Creates a forward_list with no elements.
void assign(std::initializer_list< _Tp > __il)
Assigns an initializer_list to a forward_list.
size_type max_size() const noexcept
void remove(const _Tp &__val)
Remove all elements equal to value.
Uniform interface to all pointer-like types.
Forward iterators support a superset of input iterator operations.
Uniform interface to C++98 and C++11 allocators.
static pointer allocate(_Alloc &__a, size_type __n)
Allocate memory.
static void deallocate(_Alloc &__a, pointer __p, size_type __n)
Deallocate memory.