58 #define _STL_DEQUE_H 1
65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
83 #ifndef _GLIBCXX_DEQUE_BUF_SIZE
84 #define _GLIBCXX_DEQUE_BUF_SIZE 512
88 __deque_buf_size(
size_t __size)
104 template<
typename _Tp,
typename _Ref,
typename _Ptr>
110 static size_t _S_buffer_size()
111 {
return __deque_buf_size(
sizeof(_Tp)); }
114 typedef _Tp value_type;
115 typedef _Ptr pointer;
116 typedef _Ref reference;
117 typedef size_t size_type;
118 typedef ptrdiff_t difference_type;
119 typedef _Tp** _Map_pointer;
125 _Map_pointer _M_node;
128 : _M_cur(__x), _M_first(*__y),
129 _M_last(*__y + _S_buffer_size()), _M_node(__y) { }
132 : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) { }
135 : _M_cur(__x._M_cur), _M_first(__x._M_first),
136 _M_last(__x._M_last), _M_node(__x._M_node) { }
150 if (_M_cur == _M_last)
169 if (_M_cur == _M_first)
187 operator+=(difference_type __n)
189 const difference_type __offset = __n + (_M_cur - _M_first);
190 if (__offset >= 0 && __offset < difference_type(_S_buffer_size()))
194 const difference_type __node_offset =
195 __offset > 0 ? __offset / difference_type(_S_buffer_size())
196 : -difference_type((-__offset - 1)
197 / _S_buffer_size()) - 1;
199 _M_cur = _M_first + (__offset - __node_offset
200 * difference_type(_S_buffer_size()));
206 operator+(difference_type __n)
const
213 operator-=(difference_type __n)
214 {
return *
this += -__n; }
217 operator-(difference_type __n)
const
224 operator[](difference_type __n)
const
225 {
return *(*
this + __n); }
235 _M_node = __new_node;
236 _M_first = *__new_node;
237 _M_last = _M_first + difference_type(_S_buffer_size());
244 template<
typename _Tp,
typename _Ref,
typename _Ptr>
246 operator==(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
247 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
248 {
return __x._M_cur == __y._M_cur; }
250 template<
typename _Tp,
typename _RefL,
typename _PtrL,
251 typename _RefR,
typename _PtrR>
253 operator==(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
254 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
255 {
return __x._M_cur == __y._M_cur; }
257 template<
typename _Tp,
typename _Ref,
typename _Ptr>
259 operator!=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
260 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
261 {
return !(__x == __y); }
263 template<
typename _Tp,
typename _RefL,
typename _PtrL,
264 typename _RefR,
typename _PtrR>
266 operator!=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
267 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
268 {
return !(__x == __y); }
270 template<
typename _Tp,
typename _Ref,
typename _Ptr>
272 operator<(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
273 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
274 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
275 : (__x._M_node < __y._M_node); }
277 template<
typename _Tp,
typename _RefL,
typename _PtrL,
278 typename _RefR,
typename _PtrR>
280 operator<(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
281 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
282 {
return (__x._M_node == __y._M_node) ? (__x._M_cur < __y._M_cur)
283 : (__x._M_node < __y._M_node); }
285 template<
typename _Tp,
typename _Ref,
typename _Ptr>
287 operator>(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
288 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
289 {
return __y < __x; }
291 template<
typename _Tp,
typename _RefL,
typename _PtrL,
292 typename _RefR,
typename _PtrR>
294 operator>(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
295 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
296 {
return __y < __x; }
298 template<
typename _Tp,
typename _Ref,
typename _Ptr>
300 operator<=(const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
301 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
302 {
return !(__y < __x); }
304 template<
typename _Tp,
typename _RefL,
typename _PtrL,
305 typename _RefR,
typename _PtrR>
307 operator<=(const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
308 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
309 {
return !(__y < __x); }
311 template<
typename _Tp,
typename _Ref,
typename _Ptr>
313 operator>=(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
314 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
315 {
return !(__x < __y); }
317 template<
typename _Tp,
typename _RefL,
typename _PtrL,
318 typename _RefR,
typename _PtrR>
320 operator>=(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
321 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
322 {
return !(__x < __y); }
328 template<
typename _Tp,
typename _Ref,
typename _Ptr>
329 inline typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
330 operator-(
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x,
331 const _Deque_iterator<_Tp, _Ref, _Ptr>& __y)
333 return typename _Deque_iterator<_Tp, _Ref, _Ptr>::difference_type
334 (_Deque_iterator<_Tp, _Ref, _Ptr>::_S_buffer_size())
335 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
336 + (__y._M_last - __y._M_cur);
339 template<
typename _Tp,
typename _RefL,
typename _PtrL,
340 typename _RefR,
typename _PtrR>
341 inline typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
342 operator-(
const _Deque_iterator<_Tp, _RefL, _PtrL>& __x,
343 const _Deque_iterator<_Tp, _RefR, _PtrR>& __y)
345 return typename _Deque_iterator<_Tp, _RefL, _PtrL>::difference_type
346 (_Deque_iterator<_Tp, _RefL, _PtrL>::_S_buffer_size())
347 * (__x._M_node - __y._M_node - 1) + (__x._M_cur - __x._M_first)
348 + (__y._M_last - __y._M_cur);
351 template<
typename _Tp,
typename _Ref,
typename _Ptr>
352 inline _Deque_iterator<_Tp, _Ref, _Ptr>
353 operator+(ptrdiff_t __n,
const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
354 {
return __x + __n; }
356 template<
typename _Tp>
358 fill(
const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
359 const _Deque_iterator<_Tp, _Tp&, _Tp*>&,
const _Tp&);
361 template<
typename _Tp>
362 _Deque_iterator<_Tp, _Tp&, _Tp*>
363 copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
364 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
365 _Deque_iterator<_Tp, _Tp&, _Tp*>);
367 template<
typename _Tp>
368 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
369 copy(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
370 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
371 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
372 {
return std::copy(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
373 _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
376 template<
typename _Tp>
377 _Deque_iterator<_Tp, _Tp&, _Tp*>
378 copy_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
379 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
380 _Deque_iterator<_Tp, _Tp&, _Tp*>);
382 template<
typename _Tp>
383 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
384 copy_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
385 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
386 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
387 {
return std::copy_backward(_Deque_iterator<_Tp,
388 const _Tp&,
const _Tp*>(__first),
390 const _Tp&,
const _Tp*>(__last),
393 #ifdef __GXX_EXPERIMENTAL_CXX0X__
394 template<
typename _Tp>
395 _Deque_iterator<_Tp, _Tp&, _Tp*>
396 move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
397 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
398 _Deque_iterator<_Tp, _Tp&, _Tp*>);
400 template<
typename _Tp>
401 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
402 move(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
403 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
404 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
405 {
return std::move(_Deque_iterator<_Tp, const _Tp&, const _Tp*>(__first),
406 _Deque_iterator<_Tp, const _Tp&, const _Tp*>(__last),
409 template<
typename _Tp>
410 _Deque_iterator<_Tp, _Tp&, _Tp*>
411 move_backward(_Deque_iterator<_Tp, const _Tp&, const _Tp*>,
412 _Deque_iterator<_Tp, const _Tp&, const _Tp*>,
413 _Deque_iterator<_Tp, _Tp&, _Tp*>);
415 template<
typename _Tp>
416 inline _Deque_iterator<_Tp, _Tp&, _Tp*>
417 move_backward(_Deque_iterator<_Tp, _Tp&, _Tp*> __first,
418 _Deque_iterator<_Tp, _Tp&, _Tp*> __last,
419 _Deque_iterator<_Tp, _Tp&, _Tp*> __result)
420 {
return std::move_backward(_Deque_iterator<_Tp,
421 const _Tp&,
const _Tp*>(__first),
423 const _Tp&,
const _Tp*>(__last),
437 template<
typename _Tp,
typename _Alloc>
441 typedef _Alloc allocator_type;
444 get_allocator()
const
445 {
return allocator_type(_M_get_Tp_allocator()); }
458 _Deque_base(
const allocator_type& __a,
size_t __num_elements)
466 #ifdef __GXX_EXPERIMENTAL_CXX0X__
468 : _M_impl(__x._M_get_Tp_allocator())
471 if (__x._M_impl._M_map)
473 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
474 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
475 std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
476 std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
487 typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
489 typedef typename _Alloc::template rebind<_Tp>::other _Tp_alloc_type;
492 :
public _Tp_alloc_type
500 : _Tp_alloc_type(), _M_map(0), _M_map_size(0),
501 _M_start(), _M_finish()
504 _Deque_impl(
const _Tp_alloc_type& __a)
505 : _Tp_alloc_type(__a), _M_map(0), _M_map_size(0),
506 _M_start(), _M_finish()
511 _M_get_Tp_allocator()
512 {
return *
static_cast<_Tp_alloc_type*
>(&this->_M_impl); }
514 const _Tp_alloc_type&
515 _M_get_Tp_allocator()
const
516 {
return *
static_cast<const _Tp_alloc_type*
>(&this->_M_impl); }
519 _M_get_map_allocator()
const
520 {
return _Map_alloc_type(_M_get_Tp_allocator()); }
525 return _M_impl._Tp_alloc_type::allocate(__deque_buf_size(
sizeof(_Tp)));
529 _M_deallocate_node(_Tp* __p)
531 _M_impl._Tp_alloc_type::deallocate(__p, __deque_buf_size(
sizeof(_Tp)));
535 _M_allocate_map(
size_t __n)
536 {
return _M_get_map_allocator().allocate(__n); }
539 _M_deallocate_map(_Tp** __p,
size_t __n)
540 { _M_get_map_allocator().deallocate(__p, __n); }
544 void _M_create_nodes(_Tp** __nstart, _Tp** __nfinish);
545 void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
546 enum { _S_initial_map_size = 8 };
551 template<
typename _Tp,
typename _Alloc>
555 if (this->_M_impl._M_map)
557 _M_destroy_nodes(this->_M_impl._M_start._M_node,
558 this->_M_impl._M_finish._M_node + 1);
559 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
571 template<
typename _Tp,
typename _Alloc>
576 const size_t __num_nodes = (__num_elements/ __deque_buf_size(
sizeof(_Tp))
579 this->_M_impl._M_map_size =
std::max((
size_t) _S_initial_map_size,
580 size_t(__num_nodes + 2));
581 this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
588 _Tp** __nstart = (this->_M_impl._M_map
589 + (this->_M_impl._M_map_size - __num_nodes) / 2);
590 _Tp** __nfinish = __nstart + __num_nodes;
593 { _M_create_nodes(__nstart, __nfinish); }
596 _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
597 this->_M_impl._M_map = 0;
598 this->_M_impl._M_map_size = 0;
599 __throw_exception_again;
602 this->_M_impl._M_start._M_set_node(__nstart);
603 this->_M_impl._M_finish._M_set_node(__nfinish - 1);
604 this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
605 this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
607 % __deque_buf_size(
sizeof(_Tp)));
610 template<
typename _Tp,
typename _Alloc>
618 for (__cur = __nstart; __cur < __nfinish; ++__cur)
619 *__cur = this->_M_allocate_node();
623 _M_destroy_nodes(__nstart, __cur);
624 __throw_exception_again;
628 template<
typename _Tp,
typename _Alloc>
630 _Deque_base<_Tp, _Alloc>::
631 _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
633 for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
634 _M_deallocate_node(*__n);
718 template<
typename _Tp,
typename _Alloc = std::allocator<_Tp> >
722 typedef typename _Alloc::value_type _Alloc_value_type;
723 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
724 __glibcxx_class_requires2(_Tp, _Alloc_value_type, _SameTypeConcept)
727 typedef typename _Base::_Tp_alloc_type _Tp_alloc_type;
730 typedef _Tp value_type;
731 typedef typename _Tp_alloc_type::pointer pointer;
732 typedef typename _Tp_alloc_type::const_pointer const_pointer;
733 typedef typename _Tp_alloc_type::reference reference;
734 typedef typename _Tp_alloc_type::const_reference const_reference;
739 typedef size_t size_type;
740 typedef ptrdiff_t difference_type;
741 typedef _Alloc allocator_type;
744 typedef pointer* _Map_pointer;
746 static size_t _S_buffer_size()
747 {
return __deque_buf_size(
sizeof(_Tp)); }
751 using _Base::_M_create_nodes;
752 using _Base::_M_destroy_nodes;
753 using _Base::_M_allocate_node;
754 using _Base::_M_deallocate_node;
755 using _Base::_M_allocate_map;
756 using _Base::_M_deallocate_map;
757 using _Base::_M_get_Tp_allocator;
763 using _Base::_M_impl;
782 #ifdef __GXX_EXPERIMENTAL_CXX0X__
793 { _M_default_initialize(); }
803 deque(size_type __n,
const value_type& __value,
804 const allocator_type& __a = allocator_type())
817 deque(size_type __n,
const value_type& __value = value_type(),
818 const allocator_type& __a = allocator_type())
831 :
_Base(__x._M_get_Tp_allocator(), __x.
size())
832 { std::__uninitialized_copy_a(__x.
begin(), __x.
end(),
833 this->_M_impl._M_start,
834 _M_get_Tp_allocator()); }
836 #ifdef __GXX_EXPERIMENTAL_CXX0X__
845 :
_Base(std::move(__x)) { }
859 const allocator_type& __a = allocator_type())
882 template<
typename _InputIterator>
883 deque(_InputIterator __first, _InputIterator __last,
884 const allocator_type& __a = allocator_type())
888 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
889 _M_initialize_dispatch(__first, __last, _Integral());
898 { _M_destroy_data(
begin(),
end(), _M_get_Tp_allocator()); }
910 #ifdef __GXX_EXPERIMENTAL_CXX0X__
942 this->
assign(__l.begin(), __l.end());
958 assign(size_type __n,
const value_type& __val)
959 { _M_fill_assign(__n, __val); }
973 template<
typename _InputIterator>
975 assign(_InputIterator __first, _InputIterator __last)
977 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
978 _M_assign_dispatch(__first, __last, _Integral());
981 #ifdef __GXX_EXPERIMENTAL_CXX0X__
995 { this->
assign(__l.begin(), __l.end()); }
1001 {
return _Base::get_allocator(); }
1010 {
return this->_M_impl._M_start; }
1018 {
return this->_M_impl._M_start; }
1027 {
return this->_M_impl._M_finish; }
1036 {
return this->_M_impl._M_finish; }
1052 const_reverse_iterator
1070 const_reverse_iterator
1074 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1081 {
return this->_M_impl._M_start; }
1090 {
return this->_M_impl._M_finish; }
1097 const_reverse_iterator
1106 const_reverse_iterator
1115 {
return this->_M_impl._M_finish - this->_M_impl._M_start; }
1120 {
return _M_get_Tp_allocator().max_size(); }
1122 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1135 const size_type __len =
size();
1136 if (__new_size > __len)
1137 _M_default_append(__new_size - __len);
1138 else if (__new_size < __len)
1139 _M_erase_at_end(this->_M_impl._M_start
1140 + difference_type(__new_size));
1155 resize(size_type __new_size,
const value_type& __x)
1157 const size_type __len =
size();
1158 if (__new_size > __len)
1159 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1160 else if (__new_size < __len)
1161 _M_erase_at_end(this->_M_impl._M_start
1162 + difference_type(__new_size));
1177 resize(size_type __new_size, value_type __x = value_type())
1179 const size_type __len =
size();
1180 if (__new_size > __len)
1181 insert(this->_M_impl._M_finish, __new_size - __len, __x);
1182 else if (__new_size < __len)
1183 _M_erase_at_end(this->_M_impl._M_start
1184 + difference_type(__new_size));
1188 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1192 { std::__shrink_to_fit<deque>::_S_do_it(*
this); }
1201 {
return this->_M_impl._M_finish == this->_M_impl._M_start; }
1217 {
return this->_M_impl._M_start[difference_type(__n)]; }
1232 {
return this->_M_impl._M_start[difference_type(__n)]; }
1239 if (__n >= this->
size())
1240 __throw_out_of_range(__N(
"deque::_M_range_check"));
1259 return (*
this)[__n];
1277 return (*
this)[__n];
1286 {
return *
begin(); }
1294 {
return *
begin(); }
1333 if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
1335 this->_M_impl.construct(this->_M_impl._M_start._M_cur - 1, __x);
1336 --this->_M_impl._M_start._M_cur;
1342 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1345 { emplace_front(std::move(__x)); }
1347 template<
typename... _Args>
1349 emplace_front(_Args&&... __args);
1364 if (this->_M_impl._M_finish._M_cur
1365 != this->_M_impl._M_finish._M_last - 1)
1367 this->_M_impl.construct(this->_M_impl._M_finish._M_cur, __x);
1368 ++this->_M_impl._M_finish._M_cur;
1374 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1377 { emplace_back(std::move(__x)); }
1379 template<
typename... _Args>
1381 emplace_back(_Args&&... __args);
1395 if (this->_M_impl._M_start._M_cur
1396 != this->_M_impl._M_start._M_last - 1)
1398 this->_M_impl.destroy(this->_M_impl._M_start._M_cur);
1399 ++this->_M_impl._M_start._M_cur;
1416 if (this->_M_impl._M_finish._M_cur
1417 != this->_M_impl._M_finish._M_first)
1419 --this->_M_impl._M_finish._M_cur;
1420 this->_M_impl.destroy(this->_M_impl._M_finish._M_cur);
1426 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1436 template<
typename... _Args>
1453 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1465 {
return emplace(__position, std::move(__x)); }
1478 { this->
insert(__p, __l.begin(), __l.end()); }
1492 { _M_fill_insert(__position, __n, __x); }
1504 template<
typename _InputIterator>
1507 _InputIterator __last)
1510 typedef typename std::__is_integer<_InputIterator>::__type _Integral;
1511 _M_insert_dispatch(__position, __first, __last, _Integral());
1561 std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
1562 std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
1563 std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
1564 std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
1568 std::__alloc_swap<_Tp_alloc_type>::_S_do_it(_M_get_Tp_allocator(),
1569 __x._M_get_Tp_allocator());
1580 { _M_erase_at_end(
begin()); }
1589 template<
typename _Integer>
1591 _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type)
1598 template<
typename _InputIterator>
1600 _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
1603 typedef typename std::iterator_traits<_InputIterator>::
1604 iterator_category _IterCategory;
1620 template<
typename _InputIterator>
1626 template<
typename _ForwardIterator>
1645 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1648 _M_default_initialize();
1658 template<
typename _Integer>
1660 _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
1661 { _M_fill_assign(__n, __val); }
1664 template<
typename _InputIterator>
1666 _M_assign_dispatch(_InputIterator __first, _InputIterator __last,
1669 typedef typename std::iterator_traits<_InputIterator>::
1670 iterator_category _IterCategory;
1671 _M_assign_aux(__first, __last, _IterCategory());
1675 template<
typename _InputIterator>
1677 _M_assign_aux(_InputIterator __first, _InputIterator __last,
1681 template<
typename _ForwardIterator>
1683 _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
1689 _ForwardIterator __mid = __first;
1691 std::copy(__first, __mid,
begin());
1695 _M_erase_at_end(std::copy(__first, __last,
begin()));
1701 _M_fill_assign(size_type __n,
const value_type& __val)
1710 _M_erase_at_end(
begin() + difference_type(__n));
1717 #ifndef __GXX_EXPERIMENTAL_CXX0X__
1722 template<
typename... _Args>
1725 template<
typename... _Args>
1741 template<
typename _Integer>
1743 _M_insert_dispatch(iterator __pos,
1744 _Integer __n, _Integer __x, __true_type)
1745 { _M_fill_insert(__pos, __n, __x); }
1748 template<
typename _InputIterator>
1750 _M_insert_dispatch(iterator __pos,
1751 _InputIterator __first, _InputIterator __last,
1754 typedef typename std::iterator_traits<_InputIterator>::
1755 iterator_category _IterCategory;
1756 _M_range_insert_aux(__pos, __first, __last, _IterCategory());
1760 template<
typename _InputIterator>
1762 _M_range_insert_aux(iterator __pos, _InputIterator __first,
1766 template<
typename _ForwardIterator>
1768 _M_range_insert_aux(iterator __pos, _ForwardIterator __first,
1775 _M_fill_insert(iterator __pos, size_type __n,
const value_type& __x);
1778 #ifndef __GXX_EXPERIMENTAL_CXX0X__
1780 _M_insert_aux(iterator __pos,
const value_type& __x);
1782 template<
typename... _Args>
1784 _M_insert_aux(iterator __pos, _Args&&... __args);
1789 _M_insert_aux(iterator __pos, size_type __n,
const value_type& __x);
1792 template<
typename _ForwardIterator>
1794 _M_insert_aux(iterator __pos,
1795 _ForwardIterator __first, _ForwardIterator __last,
1802 _M_destroy_data_aux(iterator __first, iterator __last);
1806 template<
typename _Alloc1>
1808 _M_destroy_data(iterator __first, iterator __last,
const _Alloc1&)
1809 { _M_destroy_data_aux(__first, __last); }
1812 _M_destroy_data(iterator __first, iterator __last,
1815 if (!__has_trivial_destructor(value_type))
1816 _M_destroy_data_aux(__first, __last);
1821 _M_erase_at_begin(iterator __pos)
1823 _M_destroy_data(
begin(), __pos, _M_get_Tp_allocator());
1824 _M_destroy_nodes(this->_M_impl._M_start._M_node, __pos._M_node);
1825 this->_M_impl._M_start = __pos;
1831 _M_erase_at_end(iterator __pos)
1833 _M_destroy_data(__pos,
end(), _M_get_Tp_allocator());
1834 _M_destroy_nodes(__pos._M_node + 1,
1835 this->_M_impl._M_finish._M_node + 1);
1836 this->_M_impl._M_finish = __pos;
1839 #ifdef __GXX_EXPERIMENTAL_CXX0X__
1842 _M_default_append(size_type __n);
1850 const size_type __vacancies = this->_M_impl._M_start._M_cur
1851 - this->_M_impl._M_start._M_first;
1852 if (__n > __vacancies)
1854 return this->_M_impl._M_start - difference_type(__n);
1860 const size_type __vacancies = (this->_M_impl._M_finish._M_last
1861 - this->_M_impl._M_finish._M_cur) - 1;
1862 if (__n > __vacancies)
1864 return this->_M_impl._M_finish + difference_type(__n);
1886 if (__nodes_to_add + 1 > this->_M_impl._M_map_size
1887 - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
1894 if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node
1895 - this->_M_impl._M_map))
1915 template<
typename _Tp,
typename _Alloc>
1933 template<
typename _Tp,
typename _Alloc>
1935 operator<(const deque<_Tp, _Alloc>& __x,
1938 __y.begin(), __y.end()); }
1941 template<
typename _Tp,
typename _Alloc>
1945 {
return !(__x == __y); }
1948 template<
typename _Tp,
typename _Alloc>
1952 {
return __y < __x; }
1955 template<
typename _Tp,
typename _Alloc>
1957 operator<=(const deque<_Tp, _Alloc>& __x,
1959 {
return !(__y < __x); }
1962 template<
typename _Tp,
typename _Alloc>
1966 {
return !(__x < __y); }
1969 template<
typename _Tp,
typename _Alloc>
1974 #undef _GLIBCXX_DEQUE_BUF_SIZE
1976 _GLIBCXX_END_NAMESPACE_CONTAINER
allocator_type get_allocator() const
Get a copy of the memory allocation object.
deque(deque &&__x)
Deque move constructor.
deque()
Default constructor creates no elements.
const_iterator cbegin() const
deque(const allocator_type &__a)
Creates a deque with no elements.
complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
void _M_push_front_aux(_Args &&...__args)
Helper functions for push_* and pop_*.
void _M_reserve_map_at_back(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
deque(_InputIterator __first, _InputIterator __last, const allocator_type &__a=allocator_type())
Builds a deque from a range.
const_reference operator[](size_type __n) const
Subscript access to the data contained in the deque.
const_iterator end() const
void _M_pop_front_aux()
Helper functions for push_* and pop_*.
const_reverse_iterator crend() const
deque & operator=(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
size_type max_size() const
#define _GLIBCXX_DEQUE_BUF_SIZE
This function controls the size of memory nodes.
const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
void insert(iterator __position, size_type __n, const value_type &__x)
Inserts a number of copies of given data into the deque.
iterator insert(iterator __position, const value_type &__x)
Inserts given value into deque before specified iterator.
void _M_reserve_map_at_front(size_type __nodes_to_add=1)
Memory-handling helpers for the major map.
void insert(iterator __position, _InputIterator __first, _InputIterator __last)
Inserts a range into the deque.
void _M_push_back_aux(_Args &&...__args)
Helper functions for push_* and pop_*.
const_reverse_iterator crbegin() const
Forward iterators support a superset of input iterator operations.
const_reference front() const
const_reference back() const
void pop_back()
Removes last element.
const_iterator begin() const
void _M_range_initialize(_InputIterator __first, _InputIterator __last, std::input_iterator_tag)
Fills the deque with whatever is in [first,last).
A standard container using fixed-size memory allocation and constant-time manipulation of elements at...
void _M_new_elements_at_back(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
bool equal(_II1 __first1, _II1 __last1, _II2 __first2)
Tests a range for element-wise equality.
void _M_set_node(_Map_pointer __new_node)
void _M_range_check(size_type __n) const
Safety check used only from at().
void push_front(const value_type &__x)
Add data to the front of the deque.
void pop_front()
Removes first element.
reference at(size_type __n)
Provides access to the data contained in the deque.
iterator _M_reserve_elements_at_back(size_type __n)
Memory-handling helpers for the previous internal insert functions.
const_reverse_iterator rbegin() const
iterator erase(iterator __position)
Remove element at given position.
bool lexicographical_compare(_II1 __first1, _II1 __last1, _II2 __first2, _II2 __last2, _Compare __comp)
Performs dictionary comparison on ranges.
void _M_new_elements_at_front(size_type __new_elements)
Memory-handling helpers for the previous internal insert functions.
iterator insert(iterator __position, value_type &&__x)
Inserts given rvalue into deque before specified iterator.
const_reference at(size_type __n) const
Provides access to the data contained in the deque.
void _M_fill_initialize(const value_type &__value)
Fills the deque with copies of value.
void assign(_InputIterator __first, _InputIterator __last)
Assigns a range to a deque.
deque(size_type __n)
Creates a deque with default constructed elements.
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
deque(size_type __n, const value_type &__value, const allocator_type &__a=allocator_type())
Creates a deque with copies of an exemplar element.
void push_back(const value_type &__x)
Add data to the end of the deque.
const_iterator cend() const
void _M_initialize_map(size_t)
Layout storage.
void assign(initializer_list< value_type > __l)
Assigns an initializer list to a deque.
iterator emplace(iterator __position, _Args &&...__args)
Inserts an object in deque before specified iterator.
complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
const_reverse_iterator rend() const
void _M_pop_back_aux()
Helper functions for push_* and pop_*.
void resize(size_type __new_size)
Resizes the deque to the specified number of elements.
void resize(size_type __new_size, const value_type &__x)
Resizes the deque to the specified number of elements.
Random-access iterators support a superset of bidirectional iterator operations.
deque & operator=(deque &&__x)
Deque move assignment operator.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
void assign(size_type __n, const value_type &__val)
Assigns a given value to a deque.
deque & operator=(const deque &__x)
Deque assignment operator.
void insert(iterator __p, initializer_list< value_type > __l)
Inserts an initializer list into the deque.
reverse_iterator rbegin()
The standard allocator, as per [20.4].Further details: http://gcc.gnu.org/onlinedocs/libstdc++/manual...
void swap(deque &__x)
Swaps data with another deque.
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.
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
Memory-handling helpers for the major map.
iterator _M_reserve_elements_at_front(size_type __n)
Memory-handling helpers for the previous internal insert functions.
deque(const deque &__x)
Deque copy constructor.