58 #define _STL_DEQUE_H 1
63 #ifdef __GXX_EXPERIMENTAL_CXX0X__
67 namespace std _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
85 #ifndef _GLIBCXX_DEQUE_BUF_SIZE
86 #define _GLIBCXX_DEQUE_BUF_SIZE 512
90 __deque_buf_size(
size_t __size)
106 template<
typename _Tp,
typename _Ref,
typename _Ptr>
112 static size_t _S_buffer_size()
113 {
return __deque_buf_size(
sizeof(_Tp)); }
116 typedef _Tp value_type;
117 typedef _Ptr pointer;
118 typedef _Ref reference;
119 typedef size_t size_type;
120 typedef ptrdiff_t difference_type;
121 typedef _Tp** _Map_pointer;
127 _Map_pointer _M_node;
130 : _M_cur(__x), _M_first(*__y),
131 _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
134 : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) { }
137 : _M_cur(__x._M_cur), _M_first(__x._M_first),
138 _M_last(__x._M_last), _M_node(__x._M_node) { }
152 if (_M_cur == _M_last)
171 if (_M_cur == _M_first)
189 operator+=(difference_type __n)
191 const difference_type __offset = __n + (_M_cur - _M_first);
192 if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
196 const difference_type __node_offset =
197 __offset > 0 ? __offset / difference_type(_S_buffer_size())
198 : -difference_type((-__offset - 1)
199 / _S_buffer_size()) - 1;
201 _M_cur = _M_first + (__offset - __node_offset
202 * difference_type(_S_buffer_size()));
208 operator+(difference_type __n)
const
215 operator-=(difference_type __n)
216 {
return *
this += -__n; }
219 operator-(difference_type __n)
const
226 operator[](difference_type __n)
const
227 {
return *(*
this + __n); }
237 _M_node = __new_node;
238 _M_first = *__new_node;
239 _M_last = _M_first + difference_type(_S_buffer_size());
246 template<
typename _Tp,
typename _Ref,
typename _Ptr>
248 operator==(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
249 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
250 {
return __x._M_cur == __y._M_cur; }
252 template<
typename _Tp,
typename _RefL,
typename _PtrL,
253 typename _RefR,
typename _PtrR>
255 operator==(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
256 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
257 {
return __x._M_cur == __y._M_cur; }
259 template<
typename _Tp,
typename _Ref,
typename _Ptr>
261 operator!=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
262 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
263 {
return !(__x == __y); }
265 template<
typename _Tp,
typename _RefL,
typename _PtrL,
266 typename _RefR,
typename _PtrR>
268 operator!=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
269 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
270 {
return !(__x == __y); }
272 template<
typename _Tp,
typename _Ref,
typename _Ptr>
274 operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
275 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
276 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
277 : (__x._M_node < __y._M_node); }
279 template<
typename _Tp,
typename _RefL,
typename _PtrL,
280 typename _RefR,
typename _PtrR>
282 operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
283 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
284 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
285 : (__x._M_node < __y._M_node); }
287 template<
typename _Tp,
typename _Ref,
typename _Ptr>
289 operator>(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
290 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
291 {
return __y < __x; }
293 template<
typename _Tp,
typename _RefL,
typename _PtrL,
294 typename _RefR,
typename _PtrR>
296 operator>(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
297 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
298 {
return __y < __x; }
300 template<
typename _Tp,
typename _Ref,
typename _Ptr>
302 operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
303 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
304 {
return !(__y < __x); }
306 template<
typename _Tp,
typename _RefL,
typename _PtrL,
307 typename _RefR,
typename _PtrR>
309 operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
310 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
311 {
return !(__y < __x); }
313 template<
typename _Tp,
typename _Ref,
typename _Ptr>
315 operator>=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
316 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
317 {
return !(__x < __y); }
319 template<
typename _Tp,
typename _RefL,
typename _PtrL,
320 typename _RefR,
typename _PtrR>
322 operator>=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
323 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
324 {
return !(__x < __y); }
330 template<
typename _Tp,
typename _Ref,
typename _Ptr>
331 inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
332 operator-(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
333 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
335 return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
336 (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size())
337 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
338 + (__y._M_last - __y._M_cur);
341 template<
typename _Tp,
typename _RefL,
typename _PtrL,
342 typename _RefR,
typename _PtrR>
343 inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
344 operator-(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
345 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
347 return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
348 (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size())
349 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
350 + (__y._M_last - __y._M_cur);
353 template<
typename _Tp,
typename _Ref,
typename _Ptr>
354 inline _Deque_iterator<_Tp, _Ref, _Ptr>
355 operator+(ptrdiff_t __n,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
356 {
return __x + __n; }
358 template<
typename _Tp>
360 fill(
const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
361 const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _Tp&);
363 template<
typename _Tp>
364 _Deque_iterator<_Tp, _Tp&, _Tp*>
365 copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
366 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
367 _Deque_iterator<_Tp, _Tp&, _Tp*>);
369 template<
typename _Tp>
370 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
371 copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
372 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
373 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
374 {
return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
375 _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
378 template<
typename _Tp>
379 _Deque_iterator<_Tp, _Tp&, _Tp*>
380 copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
381 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
382 _Deque_iterator<_Tp, _Tp&, _Tp*>);
384 template<
typename _Tp>
385 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
386 copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
387 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
388 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
389 {
return std::copy_backward(_Deque_iterator<_Tp,
390 const _Tp&,
const _Tp*>(__first),
392 const _Tp&,
const _Tp*>(__last),
395 #ifdef __GXX_EXPERIMENTAL_CXX0X__
396 template<
typename _Tp>
397 _Deque_iterator<_Tp, _Tp&, _Tp*>
398 move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
399 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
400 _Deque_iterator<_Tp, _Tp&, _Tp*>);
402 template<
typename _Tp>
403 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
404 move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
405 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
406 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
407 {
return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
408 _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
411 template<
typename _Tp>
412 _Deque_iterator<_Tp, _Tp&, _Tp*>
413 move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
414 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
415 _Deque_iterator<_Tp, _Tp&, _Tp*>);
417 template<
typename _Tp>
418 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
419 move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
420 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
421 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
422 {
return std::move_backward(_Deque_iterator<_Tp,
423 const _Tp&,
const _Tp*>(__first),
425 const _Tp&,
const _Tp*>(__last),
439 template<
typename _Tp,
typename _Alloc>
443 typedef _Alloc allocator_type;
446 get_allocator()
const _GLIBCXX_NOEXCEPT
447 {
return allocator_type(_M_get_Tp_allocator()); }
460 _Deque_base(
const allocator_type& __a,
size_t __num_elements)
468 #ifdef __GXX_EXPERIMENTAL_CXX0X__
470 : _M_impl(std::move(__x._M_get_Tp_allocator()))
473 if (__x._M_impl._M_map)
475 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
476 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
477 std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
478 std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
489 typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
491 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
494 :
public _Tp_alloc_type
502 : _Tp_alloc_type(), _M_map(0), _M_map_size(0),
503 _M_start(), _M_finish()
506 _Deque_impl(
const _Tp_alloc_type& __a)
507 : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0),
508 _M_start(), _M_finish()
511 #ifdef __GXX_EXPERIMENTAL_CXX0X__
512 _Deque_impl(_Tp_alloc_type&& __a)
513 : _Tp_alloc_type(std::move(__a)), _M_map(0), _M_map_size(0),
514 _M_start(), _M_finish()
520 _M_get_Tp_allocator() _GLIBCXX_NOEXCEPT
521 {
return *
static_cast<_Tp_alloc_type*
>(&this->_M_impl); }
523 const _Tp_alloc_type&
524 _M_get_Tp_allocator()
const _GLIBCXX_NOEXCEPT
525 {
return *
static_cast<const _Tp_alloc_type*
>(&this->_M_impl); }
528 _M_get_map_allocator()
const _GLIBCXX_NOEXCEPT
529 {
return _Map_alloc_type(_M_get_Tp_allocator()); }
534 return _M_impl._Tp_alloc_type::allocate(__deque_buf_size(
sizeof(_Tp)));
538 _M_deallocate_node(_Tp* __p)
540 _M_impl._Tp_alloc_type::deallocate(__p, __deque_buf_size(
sizeof(_Tp)));
544 _M_allocate_map(
size_t __n)
545 {
return _M_get_map_allocator().allocate(__n); }
548 _M_deallocate_map(_Tp** __p,
size_t __n)
549 { _M_get_map_allocator().deallocate(__p, __n); }
553 void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
554 void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
555 enum { _S_initial_map_size = 8 };
560 template<
typename _Tp,
typename _Alloc>
564 if (this->_M_impl._M_map)
566 _M_destroy_nodes(this->_M_impl._M_start._M_node,
567 this->_M_impl._M_finish._M_node + 1);
568 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
580 template<
typename _Tp,
typename _Alloc>
585 const size_t __num_nodes = (__num_elements/ __deque_buf_size(
sizeof(_Tp))
588 this->_M_impl._M_map_size =
std::max((
size_t) _S_initial_map_size,
589 size_t(__num_nodes + 2));
590 this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
597 _Tp** __nstart = (this->_M_impl._M_map
598 + (this->_M_impl._M_map_size - __num_nodes) / 2);
599 _Tp** __nfinish = __nstart + __num_nodes;
602 { _M_create_nodes(__nstart, __nfinish); }
605 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
606 this->_M_impl._M_map = 0;
607 this->_M_impl._M_map_size = 0;
608 __throw_exception_again;
611 this->_M_impl._M_start._M_set_node(__nstart);
612 this->_M_impl._M_finish._M_set_node(__nfinish - 1);
613 this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
614 this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
616 % __deque_buf_size(
sizeof(_Tp)));
619 template<
typename _Tp,
typename _Alloc>
627 for (__cur = __nstart; __cur < __nfinish; ++__cur)
628 *__cur = this->_M_allocate_node();
632 _M_destroy_nodes(__nstart, __cur);
633 __throw_exception_again;
637 template<
typename _Tp,
typename _Alloc>
639 _Deque_base<_Tp, _Alloc>::
640 _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
642 for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
643 _M_deallocate_node(*__n);
727 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
731 typedef typename _Alloc::value_type _Alloc_value_type;
732 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
733 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
736 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
739 typedef _Tp value_type;
740 typedef typename _Tp_alloc_type::pointer pointer;
741 typedef typename _Tp_alloc_type::const_pointer const_pointer;
742 typedef typename _Tp_alloc_type::reference reference;
743 typedef typename _Tp_alloc_type::const_reference const_reference;
748 typedef size_t size_type;
749 typedef ptrdiff_t difference_type;
750 typedef _Alloc allocator_type;
753 typedef pointer* _Map_pointer;
755 static size_t _S_buffer_size()
756 {
return __deque_buf_size(
sizeof(_Tp)); }
760 using _Base::_M_create_nodes;
761 using _Base::_M_destroy_nodes;
762 using _Base::_M_allocate_node;
763 using _Base::_M_deallocate_node;
764 using _Base::_M_allocate_map;
765 using _Base::_M_deallocate_map;
766 using _Base::_M_get_Tp_allocator;
772 using _Base::_M_impl;
791 #ifdef __GXX_EXPERIMENTAL_CXX0X__
802 { _M_default_initialize(); }
812 deque(size_type __n,
const value_type& __value,
813 const allocator_type& __a = allocator_type())
826 deque(size_type __n,
const value_type& __value = value_type(),
827 const allocator_type& __a = allocator_type())
840 :
_Base(__x._M_get_Tp_allocator(), __x.
size())
841 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
842 this->_M_impl._M_start,
843 _M_get_Tp_allocator()); }
845 #ifdef __GXX_EXPERIMENTAL_CXX0X__
854 :
_Base(std::move(__x)) { }
868 const allocator_type& __a = allocator_type())
891 template<
typename _InputIterator>
892 deque(_InputIterator __first, _InputIterator __last,
893 const allocator_type& __a = allocator_type())
897 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
898 _M_initialize_dispatch(__first, __last, _Integral());
907 { _M_destroy_data(
begin(),
end(), _M_get_Tp_allocator()); }
919 #ifdef __GXX_EXPERIMENTAL_CXX0X__
951 this->
assign(__l.begin(), __l.end());
967 assign(size_type __n,
const value_type& __val)
968 { _M_fill_assign(__n, __val); }
982 template<
typename _InputIterator>
984 assign(_InputIterator __first, _InputIterator __last)
986 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
987 _M_assign_dispatch(__first, __last, _Integral());
990 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1004 { this->
assign(__l.begin(), __l.end()); }
1010 {
return _Base::get_allocator(); }
1019 {
return this->_M_impl._M_start; }
1027 {
return this->_M_impl._M_start; }
1036 {
return this->_M_impl._M_finish; }
1045 {
return this->_M_impl._M_finish; }
1061 const_reverse_iterator
1079 const_reverse_iterator
1083 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1090 {
return this->_M_impl._M_start; }
1099 {
return this->_M_impl._M_finish; }
1106 const_reverse_iterator
1115 const_reverse_iterator
1124 {
return this->_M_impl._M_finish - this->_M_impl._M_start; }
1129 {
return _M_get_Tp_allocator().max_size(); }
1131 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1144 const size_type __len =
size();
1145 if (__new_size > __len)
1146 _M_default_append(__new_size - __len);
1147 else if (__new_size < __len)
1148 _M_erase_at_end(this->_M_impl._M_start
1149 + difference_type(__new_size));
1164 resize(size_type __new_size,
const value_type& __x)
1166 const size_type __len =
size();
1167 if (__new_size > __len)
1168 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1169 else if (__new_size < __len)
1170 _M_erase_at_end(this->_M_impl._M_start
1171 + difference_type(__new_size));
1186 resize(size_type __new_size, value_type __x = value_type())
1188 const size_type __len =
size();
1189 if (__new_size > __len)
1190 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1191 else if (__new_size < __len)
1192 _M_erase_at_end(this->_M_impl._M_start
1193 + difference_type(__new_size));
1197 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1201 { _M_shrink_to_fit(); }
1210 {
return this->_M_impl._M_finish == this->_M_impl._M_start; }
1226 {
return this->_M_impl._M_start[difference_type(__n)]; }
1241 {
return this->_M_impl._M_start[difference_type(__n)]; }
1248 if (__n >= this->
size())
1249 __throw_out_of_range(__N(
"deque::_M_range_check"));
1268 return (*
this)[__n];
1286 return (*
this)[__n];
1295 {
return *
begin(); }
1303 {
return *
begin(); }
1342 if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
1344 this->_M_impl.construct(this->_M_impl._M_start._M_cur - 1, __x);
1345 --this->_M_impl._M_start._M_cur;
1351 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1354 { emplace_front(std::move(__x)); }
1356 template<
typename... _Args>
1358 emplace_front(_Args&&... __args);
1373 if (this->_M_impl._M_finish._M_cur
1374 != this->_M_impl._M_finish._M_last - 1)
1376 this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __x);
1377 ++this->_M_impl._M_finish._M_cur;
1383 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1386 { emplace_back(std::move(__x)); }
1388 template<
typename... _Args>
1390 emplace_back(_Args&&... __args);
1404 if (this->_M_impl._M_start._M_cur
1405 != this->_M_impl._M_start._M_last - 1)
1407 this->_M_impl.destroy(this->_M_impl._M_start._M_cur);
1408 ++this->_M_impl._M_start._M_cur;
1425 if (this->_M_impl._M_finish._M_cur
1426 != this->_M_impl._M_finish._M_first)
1428 --this->_M_impl._M_finish._M_cur;
1429 this->_M_impl.destroy(this->_M_impl._M_finish._M_cur);
1435 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1445 template<
typename... _Args>
1462 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1474 {
return emplace(__position, std::move(__x)); }
1487 { this->
insert(__p, __l.begin(), __l.end()); }
1501 { _M_fill_insert(__position, __n, __x); }
1513 template<
typename _InputIterator>
1516 _InputIterator __last)
1519 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1520 _M_insert_dispatch(__position, __first, __last, _Integral());
1570 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
1571 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
1572 std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
1573 std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
1577 std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
1578 __x._M_get_Tp_allocator());
1589 { _M_erase_at_end(
begin()); }
1598 template<
typename _Integer>
1600 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1607 template<
typename _InputIterator>
1609 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1612 typedef typename std::iterator_traits<_InputIterator>::
1613 iterator_category _IterCategory;
1629 template<
typename _InputIterator>
1635 template<
typename _ForwardIterator>
1654 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1657 _M_default_initialize();
1667 template<
typename _Integer>
1669 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1670 { _M_fill_assign(__n, __val); }
1673 template<
typename _InputIterator>
1675 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1678 typedef typename std::iterator_traits<_InputIterator>::
1679 iterator_category _IterCategory;
1680 _M_assign_aux(__first, __last, _IterCategory());
1684 template<
typename _InputIterator>
1686 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1690 template<
typename _ForwardIterator>
1692 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1698 _ForwardIterator __mid = __first;
1700 std::copy(__first, __mid,
begin());
1704 _M_erase_at_end(std::copy(__first, __last,
begin()));
1710 _M_fill_assign(size_type __n,
const value_type& __val)
1719 _M_erase_at_end(
begin() + difference_type(__n));
1726 #ifndef __GXX_EXPERIMENTAL_CXX0X__
1731 template<
typename... _Args>
1734 template<
typename... _Args>
1750 template<
typename _Integer>
1752 _M_insert_dispatch(iterator __pos,
1753 _Integer __n, _Integer __x, __true_type)
1754 { _M_fill_insert(__pos, __n, __x); }
1757 template<
typename _InputIterator>
1759 _M_insert_dispatch(iterator __pos,
1760 _InputIterator __first, _InputIterator __last,
1763 typedef typename std::iterator_traits<_InputIterator>::
1764 iterator_category _IterCategory;
1765 _M_range_insert_aux(__pos, __first, __last, _IterCategory());
1769 template<
typename _InputIterator>
1771 _M_range_insert_aux(iterator __pos, _InputIterator __first,
1775 template<
typename _ForwardIterator>
1777 _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
1784 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1787 #ifndef __GXX_EXPERIMENTAL_CXX0X__
1789 _M_insert_aux(iterator __pos,
const value_type& __x);
1791 template<
typename... _Args>
1793 _M_insert_aux(iterator __pos, _Args&&... __args);
1798 _M_insert_aux(iterator __pos, size_type __n,
const value_type& __x);
1801 template<
typename _ForwardIterator>
1803 _M_insert_aux(iterator __pos,
1804 _ForwardIterator __first, _ForwardIterator __last,
1811 _M_destroy_data_aux(iterator __first, iterator __last);
1815 template<
typename _Alloc1>
1817 _M_destroy_data(iterator __first, iterator __last,
const _Alloc1&)
1818 { _M_destroy_data_aux(__first, __last); }
1821 _M_destroy_data(iterator __first, iterator __last,
1824 if (!__has_trivial_destructor(value_type))
1825 _M_destroy_data_aux(__first, __last);
1830 _M_erase_at_begin(iterator __pos)
1832 _M_destroy_data(
begin(), __pos, _M_get_Tp_allocator());
1833 _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
1834 this->_M_impl._M_start = __pos;
1840 _M_erase_at_end(iterator __pos)
1842 _M_destroy_data(__pos,
end(), _M_get_Tp_allocator());
1843 _M_destroy_nodes(__pos._M_node + 1,
1844 this->_M_impl._M_finish._M_node + 1);
1845 this->_M_impl._M_finish = __pos;
1848 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1851 _M_default_append(size_type __n);
1862 const size_type __vacancies = this->_M_impl._M_start._M_cur
1863 - this->_M_impl._M_start._M_first;
1864 if (__n > __vacancies)
1866 return this->_M_impl._M_start - difference_type(__n);
1872 const size_type __vacancies = (this->_M_impl._M_finish._M_last
1873 - this->_M_impl._M_finish._M_cur) - 1;
1874 if (__n > __vacancies)
1876 return this->_M_impl._M_finish + difference_type(__n);
1898 if (__nodes_to_add + 1 > this->_M_impl._M_map_size
1899 - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
1906 if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
1907 - this->_M_impl._M_map))
1927 template<
typename _Tp,
typename _Alloc>
1945 template<
typename _Tp,
typename _Alloc>
1947 operator<(const deque<_Tp, _Alloc>& __x,
1950 __y.begin(), __y.end()); }
1953 template<
typename _Tp,
typename _Alloc>
1957 {
return !(__x == __y); }
1960 template<
typename _Tp,
typename _Alloc>
1964 {
return __y < __x; }
1967 template<
typename _Tp,
typename _Alloc>
1969 operator<=(const deque<_Tp, _Alloc>& __x,
1971 {
return !(__y < __x); }
1974 template<
typename _Tp,
typename _Alloc>
1978 {
return !(__x < __y); }
1981 template<
typename _Tp,
typename _Alloc>
1986 #undef _GLIBCXX_DEQUE_BUF_SIZE
1988 _GLIBCXX_END_NAMESPACE_CONTAINER
void insert(iterator __p, initializer_list< value_type > __l)
Inserts an initializer list into the deque.
const_reverse_iterator rend() const _GLIBCXX_NOEXCEPT
deque(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a deque with copies of an exemplar element.
void swap(deque &__x)
Swaps data with another deque.
deque & operator=(const deque &__x)
Deque assignment operator.
deque(const deque &__x)
Deque copy constructor.
void _M_reserve_map_at_front(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
const_iterator cbegin() const noexcept
iterator end() _GLIBCXX_NOEXCEPT
The standard allocator, as per [20.4].
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
Memory-handling helpers for the major map.
deque(deque &&__x)
Deque move constructor.
#define _GLIBCXX_DEQUE_BUF_SIZE
This function controls the size of memory nodes.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
deque & operator=(deque &&__x)
Deque move assignment operator.
void assign(size_type __n, const value_type &__val)
Assigns a given value to a deque.
iterator insert(iterator __position, value_type &&__x)
Inserts given rvalue into deque before specified iterator.
const_reference front() const
deque(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a deque from a range.
iterator _M_reserve_elements_at_back(size_type __n)
Memory-handling helpers for the previous internal insert functions.
reference operator[](size_type __n)
Subscript access to the data contained in the deque.
deque(initializer_list< value_type > __l, const allocator_type &__a=allocator_type())
Builds a deque from an initializer list.
const_reverse_iterator crend() const noexcept
iterator erase(iterator __position)
Remove element at given position.
size_type size() const _GLIBCXX_NOEXCEPT
void clear() _GLIBCXX_NOEXCEPT
const_reference at(size_type __n) const
Provides access to the data contained in the deque.
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
void _M_push_front_aux(_Args &&...__args)
Helper functions for push_* and pop_*.
const_iterator cend() const noexcept
const_reference operator[](size_type __n) const
Subscript access to the data contained in the deque.
void _M_push_back_aux(_Args &&...__args)
Helper functions for push_* and pop_*.
void resize(size_type __new_size)
Resizes the deque to the specified number of elements.
void insert(iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the deque.
reverse_iterator rbegin() _GLIBCXX_NOEXCEPT
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
reverse_iterator rend() _GLIBCXX_NOEXCEPT
void push_back(const value_type &__x)
Add data to the end of the deque.
void _M_new_elements_at_front(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
deque & operator=(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
iterator _M_reserve_elements_at_front(size_type __n)
Memory-handling helpers for the previous internal insert functions.
void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
Fills the deque with whatever is in [first,last).
void insert(iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the deque.
void _M_pop_back_aux()
Helper functions for push_* and pop_*.
const_reference back() const
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
bool empty() const _GLIBCXX_NOEXCEPT
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
bool equal(_II1 __first1, _II1 __last1, _II2 __first2)
Tests a range for element-wise equality.
reference at(size_type __n)
Provides access to the data contained in the deque.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
iterator insert(iterator __position, const value_type &__x)
Inserts given value into deque before specified iterator.
deque(const allocator_type &__a)
Creates a deque with no elements.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a deque.
const_reverse_iterator rbegin() const _GLIBCXX_NOEXCEPT
void pop_back()
Removes last element.
deque(size_type __n)
Creates a deque with default constructed elements.
iterator emplace(iterator __position, _Args &&...__args)
Inserts an object in deque before specified iterator.
void _M_fill_initialize(const value_type &__value)
Fills the deque with copies of value.
void push_front(const value_type &__x)
Add data to the front of the deque.
Forward iterators support a superset of input iterator operations.
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
~deque() _GLIBCXX_NOEXCEPT
void _M_new_elements_at_back(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
size_type max_size() const _GLIBCXX_NOEXCEPT
Random-access iterators support a superset of bidirectional iterator operations.
void resize(size_type __new_size, const value_type &__x)
Resizes the deque to the specified number of elements.
deque()
Default constructor creates no elements.
void _M_initialize_map(size_t)
Layout storage.
void _M_pop_front_aux()
Helper functions for push_* and pop_*.
void pop_front()
Removes first element.
const_iterator end() const _GLIBCXX_NOEXCEPT
const_iterator begin() const _GLIBCXX_NOEXCEPT
const_reverse_iterator crbegin() const noexcept
void _M_set_node(_Map_pointer __new_node)
void _M_range_check(size_type __n) const
Safety check used only from at().
allocator_type get_allocator() const _GLIBCXX_NOEXCEPT
Get a copy of the memory allocation object.
iterator begin() _GLIBCXX_NOEXCEPT