29#ifndef _STLP_INTERNAL_DEQUE_H
39template <
class _Tp,
class _Alloc >
42 _M_destroy_nodes(_M_start._M_node, this->_M_finish._M_node + 1);
43 _M_map.deallocate(_M_map._M_data, _M_map_size._M_data);
47template <
class _Tp,
class _Alloc >
49 size_t __num_nodes = __num_elements / this->
buffer_size() + 1 ;
51 _M_map_size._M_data = (
max)((
size_t) _S_initial_map_size, __num_nodes + 2);
52 _M_map._M_data = _M_map.allocate(_M_map_size._M_data);
54 _Tp** __nstart = _M_map._M_data + (_M_map_size._M_data - __num_nodes) / 2;
55 _Tp** __nfinish = __nstart + __num_nodes;
58 _M_create_nodes(__nstart, __nfinish);
60 _STLP_UNWIND((_M_map.deallocate(_M_map._M_data, _M_map_size._M_data),
61 _M_map._M_data = 0, _M_map_size._M_data = 0))
62 _M_start._M_set_node(__nstart);
63 this->_M_finish._M_set_node(__nfinish - 1);
64 _M_start._M_cur = _M_start._M_first;
65 this->_M_finish._M_cur = this->_M_finish._M_first + __num_elements % this->
buffer_size();
68template <
class _Tp,
class _Alloc >
71 _Tp** __cur = __nstart;
73 for (; __cur < __nfinish; ++__cur)
74 *__cur = _M_map_size.allocate(this->buffer_size());
79template <
class _Tp,
class _Alloc >
82 for (_Tp**
__n = __nstart;
__n < __nfinish; ++
__n)
83 _M_map_size.deallocate(*
__n, this->buffer_size());
86#if defined (_STLP_USE_PTR_SPECIALIZATIONS)
87# define deque _STLP_PTR_IMPL_NAME(deque)
88#elif defined (_STLP_DEBUG)
89# define deque _STLP_NON_DBG_NAME(deque)
94#if defined (_STLP_NESTED_TYPE_PARAM_BUG)
96# define __iterator__ _Deque_iterator<_Tp, _Nonconst_traits<_Tp> >
97# define const_iterator _Deque_iterator<_Tp, _Const_traits<_Tp> >
98# define iterator __iterator__
99# define size_type size_t
100# define value_type _Tp
102# define __iterator__ _STLP_TYPENAME_ON_RETURN_TYPE deque<_Tp, _Alloc>::iterator
105template <
class _Tp,
class _Alloc >
110 if (__len >= __x.
size())
111 erase(_STLP_STD::copy(__x.
begin(), __x.
end(), this->_M_start), this->_M_finish);
114 _STLP_STD::copy(__x.
begin(), __mid, this->_M_start);
115 insert(this->_M_finish, __mid, __x.
end());
121template <
class _Tp,
class _Alloc >
124#if !defined (_STLP_NO_MOVE_SEMANTIC)
127 if (__pos._M_cur == this->_M_start._M_cur) {
128 iterator __new_start = _M_reserve_elements_at_front(
__n);
132 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
133 this->_M_start = __new_start;
135 else if (__pos._M_cur == this->_M_finish._M_cur) {
136 iterator __new_finish = _M_reserve_elements_at_back(
__n);
140 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node+1, __new_finish._M_node+1))
141 this->_M_finish = __new_finish;
144 _M_fill_insert_aux(__pos,
__n, __x, _Movable());
147#if !defined (_STLP_MEMBER_TEMPLATES)
149template <
class _Tp,
class _Alloc >
152#if !defined (_STLP_NO_MOVE_SEMANTIC)
156 if (__pos._M_cur == this->_M_start._M_cur) {
157 iterator __new_start = _M_reserve_elements_at_front(
__n);
161 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
162 this->_M_start = __new_start;
164 else if (__pos._M_cur == this->_M_finish._M_cur) {
165 iterator __new_finish = _M_reserve_elements_at_back(
__n);
169 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
170 __new_finish._M_node + 1))
171 this->_M_finish = __new_finish;
174 _M_insert_range_aux(__pos, __first,
__last,
__n, _Movable());
177template <
class _Tp,
class _Alloc >
180#if !defined (_STLP_NO_MOVE_SEMANTIC)
184 if (__pos._M_cur == this->_M_start._M_cur) {
185 iterator __new_start = _M_reserve_elements_at_front(
__n);
189 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
190 this->_M_start = __new_start;
192 else if (__pos._M_cur == this->_M_finish._M_cur) {
193 iterator __new_finish = _M_reserve_elements_at_back(
__n);
197 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1,
198 __new_finish._M_node + 1))
199 this->_M_finish = __new_finish;
202 _M_insert_range_aux(__pos, __first,
__last,
__n, _Movable());
207template <
class _Tp,
class _Alloc >
214 iterator __src = __pos, __dst = __pos;
215 _STLP_STD::_Destroy(&(*__dst));
216 if (__src != this->_M_start) {
217 for (--__src; __dst != this->_M_start; --__src, --__dst) {
218 _STLP_STD::_Move_Construct(&(*__dst), *__src);
219 _STLP_STD::_Destroy_Moved(&(*__src));
225 iterator __src = __pos, __dst = __pos;
226 _STLP_STD::_Destroy(&(*__dst));
227 for (++__src; __src != this->_M_finish; ++__src, ++__dst) {
228 _STLP_STD::_Move_Construct(&(*__dst), *__src);
229 _STLP_STD::_Destroy_Moved(&(*__src));
232 if (this->_M_finish._M_cur != this->_M_finish._M_first) {
233 --this->_M_finish._M_cur;
239 return this->_M_start + __index;
242template <
class _Tp,
class _Alloc >
253 _STLP_STD::copy(__next, this->_M_finish, __pos);
256 return this->_M_start + __index;
259template <
class _Tp,
class _Alloc >
266 if (__src != this->_M_start) {
267 for (--__src, --__dst; (__src >= this->_M_start) && (__dst >= __first); --__src, --__dst) {
268 _STLP_STD::_Destroy(&(*__dst));
269 _STLP_STD::_Move_Construct(&(*__dst), *__src);
271 if (__dst >= __first) {
273 _STLP_STD::_Destroy_Range(__first, ++__dst);
274 _STLP_STD::_Destroy_Moved_Range(this->_M_start, __first);
278 for (; __src >= this->_M_start; --__src, --__dst) {
279 _STLP_STD::_Destroy_Moved(&(*__dst));
280 _STLP_STD::_Move_Construct(&(*__dst), *__src);
282 _STLP_STD::_Destroy_Moved_Range(this->_M_start, ++__dst);
286 _STLP_STD::_Destroy_Range(this->_M_start,
__last);
289 this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
290 this->_M_start = __new_start;
293 if (
__last != this->_M_finish) {
295 for (; (__src != this->_M_finish) && (__dst !=
__last); ++__src, ++__dst) {
296 _STLP_STD::_Destroy(&(*__dst));
297 _STLP_STD::_Move_Construct(&(*__dst), *__src);
301 _STLP_STD::_Destroy_Range(__dst,
__last);
302 _STLP_STD::_Destroy_Moved_Range(
__last, this->_M_finish);
306 for (; __src != this->_M_finish; ++__src, ++__dst) {
307 _STLP_STD::_Destroy_Moved(&(*__dst));
308 _STLP_STD::_Move_Construct(&(*__dst), *__src);
310 _STLP_STD::_Destroy_Moved_Range(__dst, this->_M_finish);
314 _STLP_STD::_Destroy_Range(__first, this->_M_finish);
317 this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
318 this->_M_finish = __new_finish;
320 return this->_M_start + __elems_before;
323template <
class _Tp,
class _Alloc >
331 _STLP_STD::_Destroy_Range(this->_M_start, __new_start);
332 this->_M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
333 this->_M_start = __new_start;
336 _STLP_STD::copy(
__last, this->_M_finish, __first);
338 _STLP_STD::_Destroy_Range(__new_finish, this->_M_finish);
339 this->_M_destroy_nodes(__new_finish._M_node + 1, this->_M_finish._M_node + 1);
340 this->_M_finish = __new_finish;
342 return this->_M_start + __elems_before;
345template <
class _Tp,
class _Alloc >
348 __node < this->_M_finish._M_node;
350 _STLP_STD::_Destroy_Range(*__node, *__node + this->
buffer_size());
351 this->_M_map_size.deallocate(*__node, this->
buffer_size());
354 if (this->_M_start._M_node != this->_M_finish._M_node) {
355 _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_start._M_last);
356 _STLP_STD::_Destroy_Range(this->_M_finish._M_first, this->_M_finish._M_cur);
357 this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
360 _STLP_STD::_Destroy_Range(this->_M_start._M_cur, this->_M_finish._M_cur);
362 this->_M_finish = this->_M_start;
367template <
class _Tp,
class _Alloc >
372 for (; __cur < this->_M_finish._M_node; ++__cur)
381template <
class _Tp,
class _Alloc >
383 _M_reserve_map_at_back();
384 *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
387 this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
388 this->_M_finish._M_cur = this->_M_finish._M_first;
390 _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
391 this->buffer_size()))
394#if defined(_STLP_DONT_SUP_DFLT_PARAM) && !defined(_STLP_NO_ANACHRONISMS)
396template <
class _Tp,
class _Alloc >
398 _M_reserve_map_at_back();
399 *(this->_M_finish._M_node + 1) = this->_M_map_size.allocate(this->buffer_size());
401 _STLP_STD::_Construct(this->_M_finish._M_cur);
402 this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
403 this->_M_finish._M_cur = this->_M_finish._M_first;
405 _STLP_UNWIND(this->_M_map_size.deallocate(*(this->_M_finish._M_node + 1),
406 this->buffer_size()))
411template <
class _Tp,
class _Alloc >
413 _M_reserve_map_at_front();
414 *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
416 this->_M_start._M_set_node(this->_M_start._M_node - 1);
417 this->_M_start._M_cur = this->_M_start._M_last - 1;
421 this->_M_map_size.deallocate(*(this->_M_start._M_node - 1), this->buffer_size())))
425#if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
427template <
class _Tp,
class _Alloc >
429 _M_reserve_map_at_front();
430 *(this->_M_start._M_node - 1) = this->_M_map_size.allocate(this->buffer_size());
432 this->_M_start._M_set_node(this->_M_start._M_node - 1);
433 this->_M_start._M_cur = this->_M_start._M_last - 1;
434 _STLP_STD::_Construct(this->_M_start._M_cur);
436 _STLP_UNWIND((++this->_M_start, this->_M_map_size.deallocate(*(this->_M_start._M_node - 1),
437 this->buffer_size())))
442template <
class _Tp,
class _Alloc >
444 this->_M_map_size.deallocate(this->_M_finish._M_first, this->buffer_size());
445 this->_M_finish._M_set_node(this->_M_finish._M_node - 1);
446 this->_M_finish._M_cur = this->_M_finish._M_last - 1;
452template <
class _Tp,
class _Alloc >
454 if (this->_M_start._M_cur != this->_M_start._M_last - 1)
455 ++this->_M_start._M_cur;
457 this->_M_map_size.deallocate(this->_M_start._M_first, this->buffer_size());
458 this->_M_start._M_set_node(this->_M_start._M_node + 1);
459 this->_M_start._M_cur = this->_M_start._M_first;
463template <
class _Tp,
class _Alloc >
471 iterator __new_start = _M_reserve_elements_at_front(
__n);
472 __pos = this->_M_start + __elems_before;
476 for (; __src != __pos; ++__dst, ++__src) {
477 _STLP_STD::_Move_Construct(&(*__dst), *__src);
478 _STLP_STD::_Destroy_Moved(&(*__src));
480 this->_M_start = __new_start;
484 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
487 iterator __new_finish = _M_reserve_elements_at_back(
__n);
489 __pos = this->_M_finish - __elems_after;
493 for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
494 _STLP_STD::_Move_Construct(&(*__dst), *__src);
495 _STLP_STD::_Destroy_Moved(&(*__src));
497 this->_M_finish = __new_finish;
500 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
505template <
class _Tp,
class _Alloc >
513 iterator __new_start = _M_reserve_elements_at_front(
__n);
514 iterator __old_start = this->_M_start;
515 __pos = this->_M_start + __elems_before;
520 this->_M_start = __new_start;
521 _STLP_STD::copy(__start_n, __pos, __old_start);
527 this->_M_start, __x_copy);
528 this->_M_start = __new_start;
529 fill(__old_start, __pos, __x_copy);
532 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
535 iterator __new_finish = _M_reserve_elements_at_back(
__n);
536 iterator __old_finish = this->_M_finish;
539 __pos = this->_M_finish - __elems_after;
544 this->_M_finish = __new_finish;
550 __x_copy, __pos, this->_M_finish);
551 this->_M_finish = __new_finish;
552 fill(__pos, __old_finish, __x_copy);
555 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
560#if !defined (_STLP_MEMBER_TEMPLATES)
561template <
class _Tp,
class _Alloc >
568 iterator __new_start = _M_reserve_elements_at_front(
__n);
569 __pos = this->_M_start + __elems_before;
573 for (; __src != __pos; ++__dst, ++__src) {
574 _STLP_STD::_Move_Construct(&(*__dst), *__src);
575 _STLP_STD::_Destroy_Moved(&(*__src));
577 this->_M_start = __new_start;
580 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
583 iterator __new_finish = _M_reserve_elements_at_back(
__n);
584 const difference_type __elems_after = difference_type(__length) - __elems_before;
585 __pos = this->_M_finish - __elems_after;
589 for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
590 _STLP_STD::_Move_Construct(&(*__dst), *__src);
591 _STLP_STD::_Destroy_Moved(&(*__src));
593 this->_M_finish = __new_finish;
596 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
600template <
class _Tp,
class _Alloc >
607 iterator __new_start = _M_reserve_elements_at_front(
__n);
608 iterator __old_start = this->_M_start;
609 __pos = this->_M_start + __elems_before;
614 this->_M_start = __new_start;
615 _STLP_STD::copy(__start_n, __pos, __old_start);
621 this->_M_start = __new_start;
622 _STLP_STD::copy(__mid,
__last, __old_start);
625 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
628 iterator __new_finish = _M_reserve_elements_at_back(
__n);
629 iterator __old_finish = this->_M_finish;
632 __pos = this->_M_finish - __elems_after;
638 this->_M_finish = __new_finish;
639 _STLP_STD::copy_backward(__pos, __finish_n, __old_finish);
640 _STLP_STD::copy(__first,
__last, __pos);
643 const value_type* __mid = __first + __elems_after;
645 this->_M_finish = __new_finish;
646 _STLP_STD::copy(__first, __mid, __pos);
649 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
653template <
class _Tp,
class _Alloc >
660 iterator __new_start = _M_reserve_elements_at_front(
__n);
661 __pos = this->_M_start + __elems_before;
665 for (; __src != __pos; ++__dst, ++__src) {
666 _STLP_STD::_Move_Construct(&(*__dst), *__src);
667 _STLP_STD::_Destroy_Moved(&(*__src));
669 this->_M_start = __new_start;
672 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
675 iterator __new_finish = _M_reserve_elements_at_back(
__n);
677 __pos = this->_M_finish - __elems_after;
681 for (--__src, --__dst; __src >= __pos; --__src, --__dst) {
682 _STLP_STD::_Move_Construct(&(*__dst), *__src);
683 _STLP_STD::_Destroy_Moved(&(*__src));
685 this->_M_finish = __new_finish;
688 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
692template <
class _Tp,
class _Alloc >
699 iterator __new_start = _M_reserve_elements_at_front(
__n);
700 iterator __old_start = this->_M_start;
701 __pos = this->_M_start + __elems_before;
706 this->_M_start = __new_start;
707 _STLP_STD::copy(__start_n, __pos, __old_start);
713 this->_M_start = __new_start;
714 _STLP_STD::copy(__mid,
__last, __old_start);
717 _STLP_UNWIND(this->_M_destroy_nodes(__new_start._M_node, this->_M_start._M_node))
720 iterator __new_finish = _M_reserve_elements_at_back(
__n);
721 iterator __old_finish = this->_M_finish;
723 __pos = this->_M_finish - __elems_after;
728 this->_M_finish = __new_finish;
729 _STLP_STD::copy_backward(__pos, __finish_n, __old_finish);
730 _STLP_STD::copy(__first,
__last, __pos);
735 this->_M_finish = __new_finish;
736 _STLP_STD::copy(__first, __mid, __pos);
739 _STLP_UNWIND(this->_M_destroy_nodes(this->_M_finish._M_node + 1, __new_finish._M_node + 1))
744template <
class _Tp,
class _Alloc >
748 _M_reserve_map_at_front(__new_nodes);
751 for (; __i <= __new_nodes; ++__i)
752 *(this->_M_start._M_node - __i) = this->_M_map_size.allocate(this->
buffer_size());
755 this->_M_map_size.deallocate(*(this->_M_start._M_node - __j), this->buffer_size()))
758template <
class _Tp,
class _Alloc >
762 _M_reserve_map_at_back(__new_nodes);
765 for (; __i <= __new_nodes; ++__i)
766 *(this->_M_finish._M_node + __i) = this->_M_map_size.allocate(this->
buffer_size());
769 this->_M_map_size.deallocate(*(this->_M_finish._M_node + __j), this->buffer_size()))
772template <
class _Tp,
class _Alloc >
774 bool __add_at_front) {
775 size_type __old_num_nodes = this->_M_finish._M_node - this->_M_start._M_node + 1;
776 size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
779 if (this->_M_map_size._M_data > 2 * __new_num_nodes) {
780 __new_nstart = this->_M_map._M_data + (this->_M_map_size._M_data - __new_num_nodes) / 2
781 + (__add_at_front ? __nodes_to_add : 0);
782 if (__new_nstart < this->_M_start._M_node)
783 _STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
785 _STLP_STD::copy_backward(this->_M_start._M_node, this->_M_finish._M_node + 1,
786 __new_nstart + __old_num_nodes);
790 this->_M_map_size._M_data + (
max)((
size_t)this->_M_map_size._M_data, __nodes_to_add) + 2;
793 __new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
794 + (__add_at_front ? __nodes_to_add : 0);
795 _STLP_STD::copy(this->_M_start._M_node, this->_M_finish._M_node + 1, __new_nstart);
796 this->_M_map.deallocate(this->_M_map._M_data, this->_M_map_size._M_data);
798 this->_M_map._M_data = __new_map;
799 this->_M_map_size._M_data = __new_map_size;
802 this->_M_start._M_set_node(__new_nstart);
803 this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
_STLP_INLINE_LOOP _InputIter __last
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
_STLP_MOVE_TO_STD_NAMESPACE _OutputIter copy_backward(_InputIter __first, _InputIter __last, _OutputIter __result)
_STLP_INLINE_LOOP _InputIter const _Tp & __val
void _Copy_Construct(_Tp *__p, const _Tp &__val)
_STLP_MOVE_TO_STD_NAMESPACE void uninitialized_fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__x)
_STLP_BEGIN_NAMESPACE _STLP_MOVE_TO_PRIV_NAMESPACE _OutputIter __ucopy(_InputIter __first, _InputIter __last, _OutputIter __result, _Distance *)
void __uninitialized_copy_fill(_Iter __first1, _Iter __last1, _Iter __first2, _Iter __last2, const _Tp &__x)
_STLP_MOVE_TO_PRIV_NAMESPACE _ForwardIter __uninitialized_copy_copy(_InputIter1 __first1, _InputIter1 __last1, _InputIter2 __first2, _InputIter2 __last2, _ForwardIter __result)
_ForwardIter __uninitialized_fill_copy(_ForwardIter __result, _ForwardIter __mid, const _Tp &__x, _InputIter __first, _InputIter __last)
void _M_initialize_map(size_t)
void _M_create_nodes(_Tp **__nstart, _Tp **__nfinish)
void _M_destroy_nodes(_Tp **__nstart, _Tp **__nfinish)
iterator insert(iterator __pos, const value_type &__x=_STLP_DEFAULT_CONSTRUCTED(_Tp))
_Self & operator=(const _Self &__x)
void _M_push_back_aux_v(const value_type &)
iterator _M_fill_insert_aux(iterator __pos, size_type __n, const value_type &__x, const __true_type &)
void _M_new_elements_at_back(size_type __new_elements)
_Base::const_iterator const_iterator
void _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
iterator _M_erase(iterator __pos, const __true_type &)
ptrdiff_t difference_type
void _M_fill_initialize(const value_type &__val, const __true_type &)
void _M_push_front_aux_v(const value_type &)
void _M_new_elements_at_front(size_type __new_elements)
void _M_fill_insert(iterator __pos, size_type __n, const value_type &__x)
void _M_insert_range_aux(iterator __pos, const value_type *__first, const value_type *__last, size_type __n, const __true_type &)
#define _STLP_UNWIND(action)
#define _STLP_MOVE_TO_STD_NAMESPACE
#define _STLP_BEGIN_NAMESPACE
#define _STLP_END_NAMESPACE
#define _STLP_MOVE_TO_PRIV_NAMESPACE
static void buffer_size(GLcontext *ctx, GLuint *width, GLuint *height)