57 #define _STL_DEQUE_H 1 62 #if __cplusplus >= 201103L 66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
84 #ifndef _GLIBCXX_DEQUE_BUF_SIZE 85 #define _GLIBCXX_DEQUE_BUF_SIZE 512 88 _GLIBCXX_CONSTEXPR
inline size_t 89 __deque_buf_size(
size_t __size)
105 template<
typename _Tp,
typename _Ref,
typename _Ptr>
108 #if __cplusplus < 201103L 111 typedef _Tp* _Elt_pointer;
112 typedef _Tp** _Map_pointer;
115 template<
typename _Up>
117 template<
typename _CvTp>
122 typedef __ptr_to<_Tp> _Elt_pointer;
123 typedef __ptr_to<_Elt_pointer> _Map_pointer;
126 static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
127 {
return __deque_buf_size(
sizeof(_Tp)); }
130 typedef _Tp value_type;
131 typedef _Ptr pointer;
132 typedef _Ref reference;
133 typedef size_t size_type;
134 typedef ptrdiff_t difference_type;
138 _Elt_pointer _M_first;
139 _Elt_pointer _M_last;
140 _Map_pointer _M_node;
143 : _M_cur(__x), _M_first(*__y),
144 _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
147 : _M_cur(), _M_first(), _M_last(), _M_node() { }
150 : _M_cur(__x._M_cur), _M_first(__x._M_first),
151 _M_last(__x._M_last), _M_node(__x._M_node) { }
154 _M_const_cast()
const _GLIBCXX_NOEXCEPT
155 {
return iterator(_M_cur, _M_node); }
158 operator*()
const _GLIBCXX_NOEXCEPT
162 operator->()
const _GLIBCXX_NOEXCEPT
166 operator++() _GLIBCXX_NOEXCEPT
169 if (_M_cur == _M_last)
178 operator++(
int) _GLIBCXX_NOEXCEPT
186 operator--() _GLIBCXX_NOEXCEPT
188 if (_M_cur == _M_first)
198 operator--(
int) _GLIBCXX_NOEXCEPT
206 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
208 const difference_type __offset = __n + (_M_cur - _M_first);
209 if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
213 const difference_type __node_offset =
214 __offset > 0 ? __offset / difference_type(_S_buffer_size())
215 : -difference_type((-__offset - 1)
216 / _S_buffer_size()) - 1;
218 _M_cur = _M_first + (__offset - __node_offset
219 * difference_type(_S_buffer_size()));
225 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
232 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
233 {
return *
this += -__n; }
236 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
243 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
244 {
return *(*
this + __n); }
254 _M_node = __new_node;
255 _M_first = *__new_node;
256 _M_last = _M_first + difference_type(_S_buffer_size());
263 template<
typename _Tp,
typename _Ref,
typename _Ptr>
267 {
return __x._M_cur == __y._M_cur; }
269 template<
typename _Tp,
typename _RefL,
typename _PtrL,
270 typename _RefR,
typename _PtrR>
274 {
return __x._M_cur == __y._M_cur; }
276 template<
typename _Tp,
typename _Ref,
typename _Ptr>
280 {
return !(__x == __y); }
282 template<
typename _Tp,
typename _RefL,
typename _PtrL,
283 typename _RefR,
typename _PtrR>
287 {
return !(__x == __y); }
289 template<
typename _Tp,
typename _Ref,
typename _Ptr>
291 operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
293 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
294 : (__x._M_node < __y._M_node); }
296 template<
typename _Tp,
typename _RefL,
typename _PtrL,
297 typename _RefR,
typename _PtrR>
299 operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
301 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
302 : (__x._M_node < __y._M_node); }
304 template<
typename _Tp,
typename _Ref,
typename _Ptr>
308 {
return __y < __x; }
310 template<
typename _Tp,
typename _RefL,
typename _PtrL,
311 typename _RefR,
typename _PtrR>
315 {
return __y < __x; }
317 template<
typename _Tp,
typename _Ref,
typename _Ptr>
319 operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
321 {
return !(__y < __x); }
323 template<
typename _Tp,
typename _RefL,
typename _PtrL,
324 typename _RefR,
typename _PtrR>
326 operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
328 {
return !(__y < __x); }
330 template<
typename _Tp,
typename _Ref,
typename _Ptr>
334 {
return !(__x < __y); }
336 template<
typename _Tp,
typename _RefL,
typename _PtrL,
337 typename _RefR,
typename _PtrR>
341 {
return !(__x < __y); }
347 template<
typename _Tp,
typename _Ref,
typename _Ptr>
348 inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
352 return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
354 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
355 + (__y._M_last - __y._M_cur);
358 template<
typename _Tp,
typename _RefL,
typename _PtrL,
359 typename _RefR,
typename _PtrR>
360 inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
364 return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
366 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
367 + (__y._M_last - __y._M_cur);
370 template<
typename _Tp,
typename _Ref,
typename _Ptr>
374 {
return __x + __n; }
376 template<
typename _Tp>
381 template<
typename _Tp>
387 template<
typename _Tp>
396 template<
typename _Tp>
402 template<
typename _Tp>
408 const _Tp&,
const _Tp*>(__first),
410 const _Tp&,
const _Tp*>(__last),
413 #if __cplusplus >= 201103L 414 template<
typename _Tp>
420 template<
typename _Tp>
429 template<
typename _Tp>
435 template<
typename _Tp>
441 const _Tp&,
const _Tp*>(__first),
443 const _Tp&,
const _Tp*>(__last),
457 template<
typename _Tp,
typename _Alloc>
462 rebind<_Tp>::other _Tp_alloc_type;
465 #if __cplusplus < 201103L 467 typedef const _Tp* _Ptr_const;
469 typedef typename _Alloc_traits::pointer _Ptr;
470 typedef typename _Alloc_traits::const_pointer _Ptr_const;
473 typedef typename _Alloc_traits::template rebind<_Ptr>::other
478 typedef _Alloc allocator_type;
479 typedef typename _Alloc_traits::size_type size_type;
482 get_allocator()
const _GLIBCXX_NOEXCEPT
483 {
return allocator_type(_M_get_Tp_allocator()); }
490 { _M_initialize_map(0); }
494 { _M_initialize_map(__num_elements); }
496 _Deque_base(
const allocator_type& __a,
size_t __num_elements)
498 { _M_initialize_map(__num_elements); }
504 #if __cplusplus >= 201103L 506 : _M_impl(__x._M_move_impl())
510 : _M_impl(std::move(__x._M_get_Tp_allocator()))
512 _M_initialize_map(0);
513 if (__x._M_impl._M_map)
514 this->_M_impl._M_swap_data(__x._M_impl);
519 __gnu_cxx::__allocator_always_compares_equal<_Alloc>{})
525 if (__x.get_allocator() == __a)
527 if (__x._M_impl._M_map)
529 _M_initialize_map(0);
530 this->_M_impl._M_swap_data(__x._M_impl);
535 _M_initialize_map(__n);
543 typedef typename iterator::_Map_pointer _Map_pointer;
549 :
public _Tp_alloc_type
557 : _Tp_alloc_type(), _M_map(), _M_map_size(0),
558 _M_start(), _M_finish()
561 _Deque_impl(
const _Tp_alloc_type& __a) _GLIBCXX_NOEXCEPT
562 : _Tp_alloc_type(__a), _M_map(), _M_map_size(0),
563 _M_start(), _M_finish()
566 #if __cplusplus >= 201103L 567 _Deque_impl(_Deque_impl&&) =
default;
569 _Deque_impl(_Tp_alloc_type&& __a) noexcept
570 : _Tp_alloc_type(std::move(__a)), _M_map(), _M_map_size(0),
571 _M_start(), _M_finish()
575 void _M_swap_data(_Deque_impl& __x) _GLIBCXX_NOEXCEPT
578 swap(this->_M_start, __x._M_start);
579 swap(this->_M_finish, __x._M_finish);
580 swap(this->_M_map, __x._M_map);
581 swap(this->_M_map_size, __x._M_map_size);
586 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
587 {
return *
static_cast<_Tp_alloc_type*
>(&this->_M_impl); }
589 const _Tp_alloc_type&
590 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
591 {
return *
static_cast<const _Tp_alloc_type*
>(&this->_M_impl); }
594 _M_get_map_allocator()
const _GLIBCXX_NOEXCEPT
595 {
return _Map_alloc_type(_M_get_Tp_allocator()); }
601 return _Traits::allocate(_M_impl, __deque_buf_size(
sizeof(_Tp)));
605 _M_deallocate_node(_Ptr __p) _GLIBCXX_NOEXCEPT
608 _Traits::deallocate(_M_impl, __p, __deque_buf_size(
sizeof(_Tp)));
612 _M_allocate_map(
size_t __n)
614 _Map_alloc_type __map_alloc = _M_get_map_allocator();
615 return _Map_alloc_traits::allocate(__map_alloc, __n);
619 _M_deallocate_map(_Map_pointer __p,
size_t __n) _GLIBCXX_NOEXCEPT
621 _Map_alloc_type __map_alloc = _M_get_map_allocator();
622 _Map_alloc_traits::deallocate(__map_alloc, __p, __n);
626 void _M_initialize_map(
size_t);
627 void _M_create_nodes(_Map_pointer __nstart, _Map_pointer __nfinish);
628 void _M_destroy_nodes(_Map_pointer __nstart,
629 _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT;
630 enum { _S_initial_map_size = 8 };
634 #if __cplusplus >= 201103L 640 return std::move(_M_impl);
643 _Tp_alloc_type __alloc{_M_get_Tp_allocator()};
645 _Tp_alloc_type __sink __attribute((__unused__)) {std::move(__alloc)};
650 _Deque_impl __ret{std::move(_M_get_Tp_allocator())};
651 _M_impl._M_swap_data(__ret);
652 _M_impl._M_swap_data(__empty._M_impl);
658 template<
typename _Tp,
typename _Alloc>
662 if (this->_M_impl._M_map)
664 _M_destroy_nodes(this->_M_impl._M_start._M_node,
665 this->_M_impl._M_finish._M_node + 1);
666 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
678 template<
typename _Tp,
typename _Alloc>
683 const size_t __num_nodes = (__num_elements/ __deque_buf_size(
sizeof(_Tp))
686 this->_M_impl._M_map_size =
std::max((
size_t) _S_initial_map_size,
687 size_t(__num_nodes + 2));
688 this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
695 _Map_pointer __nstart = (this->_M_impl._M_map
696 + (this->_M_impl._M_map_size - __num_nodes) / 2);
697 _Map_pointer __nfinish = __nstart + __num_nodes;
700 { _M_create_nodes(__nstart, __nfinish); }
703 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
704 this->_M_impl._M_map = _Map_pointer();
705 this->_M_impl._M_map_size = 0;
706 __throw_exception_again;
709 this->_M_impl._M_start._M_set_node(__nstart);
710 this->_M_impl._M_finish._M_set_node(__nfinish - 1);
711 this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
712 this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
714 % __deque_buf_size(
sizeof(_Tp)));
717 template<
typename _Tp,
typename _Alloc>
725 for (__cur = __nstart; __cur < __nfinish; ++__cur)
726 *__cur = this->_M_allocate_node();
730 _M_destroy_nodes(__nstart, __cur);
731 __throw_exception_again;
735 template<
typename _Tp,
typename _Alloc>
739 _Map_pointer __nfinish) _GLIBCXX_NOEXCEPT
741 for (_Map_pointer __n = __nstart; __n < __nfinish; ++__n)
742 _M_deallocate_node(*__n);
829 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
833 typedef typename _Alloc::value_type _Alloc_value_type;
834 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
835 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
838 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
840 typedef typename _Base::_Map_pointer _Map_pointer;
843 typedef _Tp value_type;
844 typedef typename _Alloc_traits::pointer pointer;
845 typedef typename _Alloc_traits::const_pointer const_pointer;
846 typedef typename _Alloc_traits::reference reference;
847 typedef typename _Alloc_traits::const_reference const_reference;
852 typedef size_t size_type;
853 typedef ptrdiff_t difference_type;
854 typedef _Alloc allocator_type;
857 static size_t _S_buffer_size() _GLIBCXX_NOEXCEPT
858 {
return __deque_buf_size(
sizeof(_Tp)); }
861 using _Base::_M_initialize_map;
862 using _Base::_M_create_nodes;
863 using _Base::_M_destroy_nodes;
864 using _Base::_M_allocate_node;
865 using _Base::_M_deallocate_node;
866 using _Base::_M_allocate_map;
867 using _Base::_M_deallocate_map;
868 using _Base::_M_get_Tp_allocator;
874 using _Base::_M_impl;
893 #if __cplusplus >= 201103L 902 deque(size_type __n,
const allocator_type& __a = allocator_type())
904 { _M_default_initialize(); }
914 deque(size_type __n,
const value_type& __value,
915 const allocator_type& __a = allocator_type())
917 { _M_fill_initialize(__value); }
928 deque(size_type __n,
const value_type& __value = value_type(),
929 const allocator_type& __a = allocator_type())
931 { _M_fill_initialize(__value); }
942 : _Base(_Alloc_traits::_S_select_on_copy(__x._M_get_Tp_allocator()),
944 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
945 this->_M_impl._M_start,
946 _M_get_Tp_allocator()); }
948 #if __cplusplus >= 201103L 957 : _Base(
std::move(__x)) { }
961 : _Base(__a, __x.size())
962 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
963 this->_M_impl._M_start,
964 _M_get_Tp_allocator()); }
968 : _Base(
std::move(__x), __a, __x.size())
970 if (__x.get_allocator() != __a)
972 std::__uninitialized_move_a(__x.begin(), __x.end(),
973 this->_M_impl._M_start,
974 _M_get_Tp_allocator());
991 const allocator_type& __a = allocator_type())
994 _M_range_initialize(__l.begin(), __l.end(),
1014 #if __cplusplus >= 201103L 1015 template<
typename _InputIterator,
1016 typename = std::_RequireInputIter<_InputIterator>>
1017 deque(_InputIterator __first, _InputIterator __last,
1018 const allocator_type& __a = allocator_type())
1020 { _M_initialize_dispatch(__first, __last, __false_type()); }
1022 template<
typename _InputIterator>
1023 deque(_InputIterator __first, _InputIterator __last,
1024 const allocator_type& __a = allocator_type())
1028 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1029 _M_initialize_dispatch(__first, __last, _Integral());
1039 { _M_destroy_data(
begin(),
end(), _M_get_Tp_allocator()); }
1049 operator=(
const deque& __x);
1051 #if __cplusplus >= 201103L 1063 constexpr
bool __always_equal = _Alloc_traits::_S_always_equal();
1064 _M_move_assign1(std::move(__x),
1083 this->assign(__l.begin(), __l.end());
1099 assign(size_type __n,
const value_type& __val)
1100 { _M_fill_assign(__n, __val); }
1114 #if __cplusplus >= 201103L 1115 template<
typename _InputIterator,
1116 typename = std::_RequireInputIter<_InputIterator>>
1118 assign(_InputIterator __first, _InputIterator __last)
1119 { _M_assign_dispatch(__first, __last, __false_type()); }
1121 template<
typename _InputIterator>
1123 assign(_InputIterator __first, _InputIterator __last)
1125 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1126 _M_assign_dispatch(__first, __last, _Integral());
1130 #if __cplusplus >= 201103L 1144 { this->assign(__l.begin(), __l.end()); }
1150 {
return _Base::get_allocator(); }
1159 {
return this->_M_impl._M_start; }
1167 {
return this->_M_impl._M_start; }
1176 {
return this->_M_impl._M_finish; }
1185 {
return this->_M_impl._M_finish; }
1194 {
return reverse_iterator(this->_M_impl._M_finish); }
1201 const_reverse_iterator
1203 {
return const_reverse_iterator(this->_M_impl._M_finish); }
1212 {
return reverse_iterator(this->_M_impl._M_start); }
1219 const_reverse_iterator
1221 {
return const_reverse_iterator(this->_M_impl._M_start); }
1223 #if __cplusplus >= 201103L 1230 {
return this->_M_impl._M_start; }
1239 {
return this->_M_impl._M_finish; }
1246 const_reverse_iterator
1248 {
return const_reverse_iterator(this->_M_impl._M_finish); }
1255 const_reverse_iterator
1257 {
return const_reverse_iterator(this->_M_impl._M_start); }
1264 {
return this->_M_impl._M_finish - this->_M_impl._M_start; }
1269 {
return _Alloc_traits::max_size(_M_get_Tp_allocator()); }
1271 #if __cplusplus >= 201103L 1284 const size_type __len = size();
1285 if (__new_size > __len)
1286 _M_default_append(__new_size - __len);
1287 else if (__new_size < __len)
1288 _M_erase_at_end(this->_M_impl._M_start
1289 + difference_type(__new_size));
1304 resize(size_type __new_size,
const value_type& __x)
1306 const size_type __len = size();
1307 if (__new_size > __len)
1308 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1309 else if (__new_size < __len)
1310 _M_erase_at_end(this->_M_impl._M_start
1311 + difference_type(__new_size));
1326 resize(size_type __new_size, value_type __x = value_type())
1328 const size_type __len = size();
1329 if (__new_size > __len)
1330 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1331 else if (__new_size < __len)
1332 _M_erase_at_end(this->_M_impl._M_start
1333 + difference_type(__new_size));
1337 #if __cplusplus >= 201103L 1341 { _M_shrink_to_fit(); }
1350 {
return this->_M_impl._M_finish == this->_M_impl._M_start; }
1366 {
return this->_M_impl._M_start[difference_type(__n)]; }
1381 {
return this->_M_impl._M_start[difference_type(__n)]; }
1388 if (__n >= this->size())
1389 __throw_out_of_range_fmt(__N(
"deque::_M_range_check: __n " 1390 "(which is %zu)>= this->size() " 1410 _M_range_check(__n);
1411 return (*
this)[__n];
1428 _M_range_check(__n);
1429 return (*
this)[__n];
1438 {
return *
begin(); }
1446 {
return *
begin(); }
1455 iterator __tmp =
end();
1467 const_iterator __tmp =
end();
1485 if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
1487 _Alloc_traits::construct(this->_M_impl,
1488 this->_M_impl._M_start._M_cur - 1,
1490 --this->_M_impl._M_start._M_cur;
1493 _M_push_front_aux(__x);
1496 #if __cplusplus >= 201103L 1498 push_front(value_type&& __x)
1499 { emplace_front(std::move(__x)); }
1501 template<
typename... _Args>
1503 emplace_front(_Args&&... __args);
1518 if (this->_M_impl._M_finish._M_cur
1519 != this->_M_impl._M_finish._M_last - 1)
1521 _Alloc_traits::construct(this->_M_impl,
1522 this->_M_impl._M_finish._M_cur, __x);
1523 ++this->_M_impl._M_finish._M_cur;
1526 _M_push_back_aux(__x);
1529 #if __cplusplus >= 201103L 1531 push_back(value_type&& __x)
1532 { emplace_back(std::move(__x)); }
1534 template<
typename... _Args>
1536 emplace_back(_Args&&... __args);
1550 if (this->_M_impl._M_start._M_cur
1551 != this->_M_impl._M_start._M_last - 1)
1553 _Alloc_traits::destroy(this->_M_impl,
1554 this->_M_impl._M_start._M_cur);
1555 ++this->_M_impl._M_start._M_cur;
1572 if (this->_M_impl._M_finish._M_cur
1573 != this->_M_impl._M_finish._M_first)
1575 --this->_M_impl._M_finish._M_cur;
1576 _Alloc_traits::destroy(this->_M_impl,
1577 this->_M_impl._M_finish._M_cur);
1583 #if __cplusplus >= 201103L 1593 template<
typename... _Args>
1595 emplace(const_iterator __position, _Args&&... __args);
1607 insert(const_iterator __position,
const value_type& __x);
1619 insert(iterator __position,
const value_type& __x);
1622 #if __cplusplus >= 201103L 1633 insert(const_iterator __position, value_type&& __x)
1634 {
return emplace(__position, std::move(__x)); }
1647 {
return this->insert(__p, __l.begin(), __l.end()); }
1650 #if __cplusplus >= 201103L 1662 insert(const_iterator __position, size_type __n,
const value_type& __x)
1664 difference_type __offset = __position -
cbegin();
1665 _M_fill_insert(__position._M_const_cast(), __n, __x);
1666 return begin() + __offset;
1679 insert(iterator __position, size_type __n,
const value_type& __x)
1680 { _M_fill_insert(__position, __n, __x); }
1683 #if __cplusplus >= 201103L 1695 template<
typename _InputIterator,
1696 typename = std::_RequireInputIter<_InputIterator>>
1698 insert(const_iterator __position, _InputIterator __first,
1699 _InputIterator __last)
1701 difference_type __offset = __position -
cbegin();
1702 _M_insert_dispatch(__position._M_const_cast(),
1703 __first, __last, __false_type());
1704 return begin() + __offset;
1717 template<
typename _InputIterator>
1719 insert(iterator __position, _InputIterator __first,
1720 _InputIterator __last)
1723 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1724 _M_insert_dispatch(__position, __first, __last, _Integral());
1742 #if __cplusplus >= 201103L 1745 erase(iterator __position)
1747 {
return _M_erase(__position._M_const_cast()); }
1766 #if __cplusplus >= 201103L 1767 erase(const_iterator __first, const_iterator __last)
1769 erase(iterator __first, iterator __last)
1771 {
return _M_erase(__first._M_const_cast(), __last._M_const_cast()); }
1784 #if __cplusplus >= 201103L 1785 noexcept(_Alloc_traits::_S_nothrow_swap())
1788 _M_impl._M_swap_data(__x._M_impl);
1789 _Alloc_traits::_S_on_swap(_M_get_Tp_allocator(),
1790 __x._M_get_Tp_allocator());
1801 { _M_erase_at_end(
begin()); }
1810 template<
typename _Integer>
1812 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1814 _M_initialize_map(static_cast<size_type>(__n));
1815 _M_fill_initialize(__x);
1819 template<
typename _InputIterator>
1821 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1824 typedef typename std::iterator_traits<_InputIterator>::
1825 iterator_category _IterCategory;
1826 _M_range_initialize(__first, __last, _IterCategory());
1841 template<
typename _InputIterator>
1843 _M_range_initialize(_InputIterator __first, _InputIterator __last,
1847 template<
typename _ForwardIterator>
1849 _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
1864 _M_fill_initialize(
const value_type& __value);
1866 #if __cplusplus >= 201103L 1869 _M_default_initialize();
1879 template<
typename _Integer>
1881 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1882 { _M_fill_assign(__n, __val); }
1885 template<
typename _InputIterator>
1887 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1890 typedef typename std::iterator_traits<_InputIterator>::
1891 iterator_category _IterCategory;
1892 _M_assign_aux(__first, __last, _IterCategory());
1896 template<
typename _InputIterator>
1898 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1902 template<
typename _ForwardIterator>
1904 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1910 _ForwardIterator __mid = __first;
1912 std::copy(__first, __mid,
begin());
1913 insert(
end(), __mid, __last);
1916 _M_erase_at_end(std::copy(__first, __last,
begin()));
1922 _M_fill_assign(size_type __n,
const value_type& __val)
1927 insert(
end(), __n - size(), __val);
1931 _M_erase_at_end(
begin() + difference_type(__n));
1938 #if __cplusplus < 201103L 1939 void _M_push_back_aux(
const value_type&);
1941 void _M_push_front_aux(
const value_type&);
1943 template<
typename... _Args>
1944 void _M_push_back_aux(_Args&&... __args);
1946 template<
typename... _Args>
1947 void _M_push_front_aux(_Args&&... __args);
1950 void _M_pop_back_aux();
1952 void _M_pop_front_aux();
1962 template<
typename _Integer>
1964 _M_insert_dispatch(iterator __pos,
1965 _Integer __n, _Integer __x, __true_type)
1966 { _M_fill_insert(__pos, __n, __x); }
1969 template<
typename _InputIterator>
1971 _M_insert_dispatch(iterator __pos,
1972 _InputIterator __first, _InputIterator __last,
1975 typedef typename std::iterator_traits<_InputIterator>::
1976 iterator_category _IterCategory;
1977 _M_range_insert_aux(__pos, __first, __last, _IterCategory());
1981 template<
typename _InputIterator>
1983 _M_range_insert_aux(iterator __pos, _InputIterator __first,
1987 template<
typename _ForwardIterator>
1989 _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
1996 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1999 #if __cplusplus < 201103L 2001 _M_insert_aux(iterator __pos,
const value_type& __x);
2003 template<
typename... _Args>
2005 _M_insert_aux(iterator __pos, _Args&&... __args);
2010 _M_insert_aux(iterator __pos, size_type __n,
const value_type& __x);
2013 template<
typename _ForwardIterator>
2015 _M_insert_aux(iterator __pos,
2016 _ForwardIterator __first, _ForwardIterator __last,
2023 _M_destroy_data_aux(iterator __first, iterator __last);
2027 template<
typename _Alloc1>
2029 _M_destroy_data(iterator __first, iterator __last,
const _Alloc1&)
2030 { _M_destroy_data_aux(__first, __last); }
2033 _M_destroy_data(iterator __first, iterator __last,
2036 if (!__has_trivial_destructor(value_type))
2037 _M_destroy_data_aux(__first, __last);
2042 _M_erase_at_begin(iterator __pos)
2044 _M_destroy_data(
begin(), __pos, _M_get_Tp_allocator());
2045 _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
2046 this->_M_impl._M_start = __pos;
2052 _M_erase_at_end(iterator __pos)
2054 _M_destroy_data(__pos,
end(), _M_get_Tp_allocator());
2055 _M_destroy_nodes(__pos._M_node + 1,
2056 this->_M_impl._M_finish._M_node + 1);
2057 this->_M_impl._M_finish = __pos;
2061 _M_erase(iterator __pos);
2064 _M_erase(iterator __first, iterator __last);
2066 #if __cplusplus >= 201103L 2069 _M_default_append(size_type __n);
2080 const size_type __vacancies = this->_M_impl._M_start._M_cur
2081 - this->_M_impl._M_start._M_first;
2082 if (__n > __vacancies)
2083 _M_new_elements_at_front(__n - __vacancies);
2084 return this->_M_impl._M_start - difference_type(__n);
2090 const size_type __vacancies = (this->_M_impl._M_finish._M_last
2091 - this->_M_impl._M_finish._M_cur) - 1;
2092 if (__n > __vacancies)
2093 _M_new_elements_at_back(__n - __vacancies);
2094 return this->_M_impl._M_finish + difference_type(__n);
2098 _M_new_elements_at_front(size_type __new_elements);
2101 _M_new_elements_at_back(size_type __new_elements);
2116 if (__nodes_to_add + 1 > this->_M_impl._M_map_size
2117 - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
2118 _M_reallocate_map(__nodes_to_add,
false);
2124 if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
2125 - this->_M_impl._M_map))
2126 _M_reallocate_map(__nodes_to_add,
true);
2130 _M_reallocate_map(size_type __nodes_to_add,
bool __add_at_front);
2133 #if __cplusplus >= 201103L 2139 this->_M_impl._M_swap_data(__x._M_impl);
2141 std::__alloc_on_move(_M_get_Tp_allocator(), __x._M_get_Tp_allocator());
2147 constexpr
bool __move_storage =
2148 _Alloc_traits::_S_propagate_on_move_assign();
2149 _M_move_assign2(std::move(__x),
2155 template<
typename... _Args>
2157 _M_replace_map(_Args&&... __args)
2160 deque __newobj(std::forward<_Args>(__args)...);
2163 _M_deallocate_node(*
begin()._M_node);
2164 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
2165 this->_M_impl._M_map =
nullptr;
2166 this->_M_impl._M_map_size = 0;
2168 this->_M_impl._M_swap_data(__newobj._M_impl);
2176 auto __alloc = __x._M_get_Tp_allocator();
2179 _M_replace_map(std::move(__x));
2181 _M_get_Tp_allocator() = std::move(__alloc);
2189 if (__x._M_get_Tp_allocator() == this->_M_get_Tp_allocator())
2193 _M_replace_map(std::move(__x), __x.get_allocator());
2199 this->assign(std::__make_move_if_noexcept_iterator(__x.begin()),
2200 std::__make_move_if_noexcept_iterator(__x.end()));
2218 template<
typename _Tp,
typename _Alloc>
2236 template<
typename _Tp,
typename _Alloc>
2238 operator<(const deque<_Tp, _Alloc>& __x,
2241 __y.begin(), __y.end()); }
2244 template<
typename _Tp,
typename _Alloc>
2248 {
return !(__x == __y); }
2251 template<
typename _Tp,
typename _Alloc>
2255 {
return __y < __x; }
2258 template<
typename _Tp,
typename _Alloc>
2260 operator<=(const deque<_Tp, _Alloc>& __x,
2262 {
return !(__y < __x); }
2265 template<
typename _Tp,
typename _Alloc>
2269 {
return !(__x < __y); }
2272 template<
typename _Tp,
typename _Alloc>
2277 #undef _GLIBCXX_DEQUE_BUF_SIZE 2279 _GLIBCXX_END_NAMESPACE_CONTAINER
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
void shrink_to_fit() noexcept
deque & operator=(deque &&__x) noexcept(_Alloc_traits::_S_always_equal())
Deque move assignment operator.
deque(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a deque with copies of an exemplar element.
const_reverse_iterator rbegin() const noexcept
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
void _M_range_check(size_type __n) const
Safety check used only from at().
size_type max_size() const noexcept
reference at(size_type __n)
Provides access to the data contained in the deque.
const_iterator cend() const noexcept
iterator insert(const_iterator __p, initializer_list< value_type > __l)
Inserts an initializer list into the deque.
void resize(size_type __new_size)
Resizes the deque to the specified number of elements.
iterator _M_reserve_elements_at_back(size_type __n)
Memory-handling helpers for the previous internal insert functions.
void pop_back() noexcept
Removes last element.
const_reference at(size_type __n) const
Provides access to the data contained in the deque.
iterator begin() noexcept
deque(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a deque from an initializer list.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
void _M_set_node(_Map_pointer __new_node) noexcept
void _M_initialize_map(size_t)
Layout storage.
The standard allocator, as per [20.4].
iterator _M_reserve_elements_at_front(size_type __n)
Memory-handling helpers for the previous internal insert functions.
deque(size_type __n, const allocator_type &__a=allocator_type())
Creates a deque with default constructed elements.
void push_back(const value_type &__x)
Add data to the end of the deque.
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
const_reference operator[](size_type __n) const noexcept
Subscript access to the data contained in the deque.
iterator insert(const_iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the deque.
bool empty() const noexcept
deque(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a deque from a range.
const_iterator begin() const noexcept
bool equal(_IIter1 __first1, _IIter1 __last1, _IIter2 __first2, _IIter2 __last2, _BinaryPredicate __binary_pred)
Tests a range for element-wise equality.
reverse_iterator rend() noexcept
#define _GLIBCXX_DEQUE_BUF_SIZE
This function controls the size of memory nodes.
const_reference back() const noexcept
constexpr const _Tp * begin(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to the first element of the initializer_list.
void resize(size_type __new_size, const value_type &__x)
Resizes the deque to the specified number of elements.
reverse_iterator rbegin() noexcept
void assign(size_type __n, const value_type &__val)
Assigns a given value to a deque.
_GLIBCXX14_CONSTEXPR const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
const_reverse_iterator crend() const noexcept
reference front() noexcept
Random-access iterators support a superset of bidirectional iterator operations.
void _M_reserve_map_at_front(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
deque(const deque &__x)
Deque copy constructor.
const_reverse_iterator crbegin() const noexcept
allocator_type get_allocator() const noexcept
Get a copy of the memory allocation object.
deque(deque &&__x, const allocator_type &__a)
Move constructor with alternative allocator.
Uniform interface to all pointer-like types.
constexpr auto cbegin(const _Container &__cont) noexcept(noexcept(std::begin(__cont))) -> decltype(std::begin(__cont))
Return an iterator pointing to the first element of the const container.
reference operator[](size_type __n) noexcept
Subscript access to the data contained in the deque.
deque(deque &&__x)
Deque move constructor.
void swap(deque &__x) noexcept(_Alloc_traits::_S_nothrow_swap())
Swaps data with another deque.
deque()
Creates a deque with no elements.
deque(const allocator_type &__a)
Creates a deque with no elements.
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
iterator erase(const_iterator __first, const_iterator __last)
Remove a range of elements.
reference back() noexcept
deque(const deque &__x, const allocator_type &__a)
Copy constructor with alternative allocator.
const_reverse_iterator rend() const noexcept
deque & operator=(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
const_iterator cbegin() const noexcept
iterator erase(const_iterator __position)
Remove element at given position.
const_reference front() const noexcept
void push_front(const value_type &__x)
Add data to the front of the deque.
const_iterator end() const noexcept
Forward iterators support a superset of input iterator operations.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a deque.
iterator insert(const_iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the deque.
ISO C++ entities toplevel namespace is std.
constexpr const _Tp * end(initializer_list< _Tp > __ils) noexcept
Return an iterator pointing to one past the last element of the initializer_list. ...
iterator insert(const_iterator __position, value_type &&__x)
Inserts given rvalue into deque before specified iterator.
size_type size() const noexcept
Uniform interface to C++98 and C++0x allocators.
void pop_front() noexcept
Removes first element.