1 // Deque implementation -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
34 * Hewlett-Packard Company
36 * Permission to use, copy, modify, distribute and sell this software
37 * and its documentation for any purpose is hereby granted without fee,
38 * provided that the above copyright notice appear in all copies and
39 * that both that copyright notice and this permission notice appear
40 * in supporting documentation. Hewlett-Packard Company makes no
41 * representations about the suitability of this software for any
42 * purpose. It is provided "as is" without express or implied warranty.
46 * Silicon Graphics Computer Systems, Inc.
48 * Permission to use, copy, modify, distribute and sell this software
49 * and its documentation for any purpose is hereby granted without fee,
50 * provided that the above copyright notice appear in all copies and
51 * that both that copyright notice and this permission notice appear
52 * in supporting documentation. Silicon Graphics makes no
53 * representations about the suitability of this software for any
54 * purpose. It is provided "as is" without express or implied warranty.
58 * This is an internal header file, included by other library headers.
59 * You should not attempt to use it directly.
63 #define _STL_DEQUE_H 1
65 #include <bits/concept_check.h>
66 #include <bits/stl_iterator_base_types.h>
67 #include <bits/stl_iterator_base_funcs.h>
69 _GLIBCXX_BEGIN_NESTED_NAMESPACE(std
, _GLIBCXX_STD
)
73 * @brief This function controls the size of memory nodes.
74 * @param size The size of an element.
75 * @return The number (not byte size) of elements per node.
77 * This function started off as a compiler kludge from SGI, but seems to
78 * be a useful wrapper around a repeated constant expression. The '512' is
79 * tuneable (and no other code needs to change), but no investigation has
80 * been done since inheriting the SGI code.
84 __deque_buf_size(size_t __size
)
85 { return __size
< 512 ? size_t(512 / __size
) : size_t(1); }
89 * @brief A deque::iterator.
91 * Quite a bit of intelligence here. Much of the functionality of
92 * deque is actually passed off to this class. A deque holds two
93 * of these internally, marking its valid range. Access to
94 * elements is done as offsets of either of those two, relying on
95 * operator overloading in this class.
98 * All the functions are op overloads except for _M_set_node.
101 template<typename _Tp
, typename _Ref
, typename _Ptr
>
102 struct _Deque_iterator
104 typedef _Deque_iterator
<_Tp
, _Tp
&, _Tp
*> iterator
;
105 typedef _Deque_iterator
<_Tp
, const _Tp
&, const _Tp
*> const_iterator
;
107 static size_t _S_buffer_size()
108 { return __deque_buf_size(sizeof(_Tp
)); }
110 typedef std::random_access_iterator_tag iterator_category
;
111 typedef _Tp value_type
;
112 typedef _Ptr pointer
;
113 typedef _Ref reference
;
114 typedef size_t size_type
;
115 typedef ptrdiff_t difference_type
;
116 typedef _Tp
** _Map_pointer
;
117 typedef _Deque_iterator _Self
;
122 _Map_pointer _M_node
;
124 _Deque_iterator(_Tp
* __x
, _Map_pointer __y
)
125 : _M_cur(__x
), _M_first(*__y
),
126 _M_last(*__y
+ _S_buffer_size()), _M_node(__y
) {}
128 _Deque_iterator() : _M_cur(0), _M_first(0), _M_last(0), _M_node(0) {}
130 _Deque_iterator(const iterator
& __x
)
131 : _M_cur(__x
._M_cur
), _M_first(__x
._M_first
),
132 _M_last(__x
._M_last
), _M_node(__x
._M_node
) {}
146 if (_M_cur
== _M_last
)
148 _M_set_node(_M_node
+ 1);
165 if (_M_cur
== _M_first
)
167 _M_set_node(_M_node
- 1);
183 operator+=(difference_type __n
)
185 const difference_type __offset
= __n
+ (_M_cur
- _M_first
);
186 if (__offset
>= 0 && __offset
< difference_type(_S_buffer_size()))
190 const difference_type __node_offset
=
191 __offset
> 0 ? __offset
/ difference_type(_S_buffer_size())
192 : -difference_type((-__offset
- 1)
193 / _S_buffer_size()) - 1;
194 _M_set_node(_M_node
+ __node_offset
);
195 _M_cur
= _M_first
+ (__offset
- __node_offset
196 * difference_type(_S_buffer_size()));
202 operator+(difference_type __n
) const
209 operator-=(difference_type __n
)
210 { return *this += -__n
; }
213 operator-(difference_type __n
) const
220 operator[](difference_type __n
) const
221 { return *(*this + __n
); }
224 * Prepares to traverse new_node. Sets everything except
225 * _M_cur, which should therefore be set by the caller
226 * immediately afterwards, based on _M_first and _M_last.
230 _M_set_node(_Map_pointer __new_node
)
232 _M_node
= __new_node
;
233 _M_first
= *__new_node
;
234 _M_last
= _M_first
+ difference_type(_S_buffer_size());
238 // Note: we also provide overloads whose operands are of the same type in
239 // order to avoid ambiguous overload resolution when std::rel_ops operators
240 // are in scope (for additional details, see libstdc++/3628)
241 template<typename _Tp
, typename _Ref
, typename _Ptr
>
243 operator==(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
244 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
245 { return __x
._M_cur
== __y
._M_cur
; }
247 template<typename _Tp
, typename _RefL
, typename _PtrL
,
248 typename _RefR
, typename _PtrR
>
250 operator==(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
251 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
252 { return __x
._M_cur
== __y
._M_cur
; }
254 template<typename _Tp
, typename _Ref
, typename _Ptr
>
256 operator!=(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
257 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
258 { return !(__x
== __y
); }
260 template<typename _Tp
, typename _RefL
, typename _PtrL
,
261 typename _RefR
, typename _PtrR
>
263 operator!=(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
264 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
265 { return !(__x
== __y
); }
267 template<typename _Tp
, typename _Ref
, typename _Ptr
>
269 operator<(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
270 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
271 { return (__x
._M_node
== __y
._M_node
) ? (__x
._M_cur
< __y
._M_cur
)
272 : (__x
._M_node
< __y
._M_node
); }
274 template<typename _Tp
, typename _RefL
, typename _PtrL
,
275 typename _RefR
, typename _PtrR
>
277 operator<(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
278 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
279 { return (__x
._M_node
== __y
._M_node
) ? (__x
._M_cur
< __y
._M_cur
)
280 : (__x
._M_node
< __y
._M_node
); }
282 template<typename _Tp
, typename _Ref
, typename _Ptr
>
284 operator>(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
285 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
286 { return __y
< __x
; }
288 template<typename _Tp
, typename _RefL
, typename _PtrL
,
289 typename _RefR
, typename _PtrR
>
291 operator>(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
292 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
293 { return __y
< __x
; }
295 template<typename _Tp
, typename _Ref
, typename _Ptr
>
297 operator<=(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
298 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
299 { return !(__y
< __x
); }
301 template<typename _Tp
, typename _RefL
, typename _PtrL
,
302 typename _RefR
, typename _PtrR
>
304 operator<=(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
305 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
306 { return !(__y
< __x
); }
308 template<typename _Tp
, typename _Ref
, typename _Ptr
>
310 operator>=(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
311 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
312 { return !(__x
< __y
); }
314 template<typename _Tp
, typename _RefL
, typename _PtrL
,
315 typename _RefR
, typename _PtrR
>
317 operator>=(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
318 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
319 { return !(__x
< __y
); }
321 // _GLIBCXX_RESOLVE_LIB_DEFECTS
322 // According to the resolution of DR179 not only the various comparison
323 // operators but also operator- must accept mixed iterator/const_iterator
325 template<typename _Tp
, typename _Ref
, typename _Ptr
>
326 inline typename _Deque_iterator
<_Tp
, _Ref
, _Ptr
>::difference_type
327 operator-(const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
,
328 const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __y
)
330 return typename _Deque_iterator
<_Tp
, _Ref
, _Ptr
>::difference_type
331 (_Deque_iterator
<_Tp
, _Ref
, _Ptr
>::_S_buffer_size())
332 * (__x
._M_node
- __y
._M_node
- 1) + (__x
._M_cur
- __x
._M_first
)
333 + (__y
._M_last
- __y
._M_cur
);
336 template<typename _Tp
, typename _RefL
, typename _PtrL
,
337 typename _RefR
, typename _PtrR
>
338 inline typename _Deque_iterator
<_Tp
, _RefL
, _PtrL
>::difference_type
339 operator-(const _Deque_iterator
<_Tp
, _RefL
, _PtrL
>& __x
,
340 const _Deque_iterator
<_Tp
, _RefR
, _PtrR
>& __y
)
342 return typename _Deque_iterator
<_Tp
, _RefL
, _PtrL
>::difference_type
343 (_Deque_iterator
<_Tp
, _RefL
, _PtrL
>::_S_buffer_size())
344 * (__x
._M_node
- __y
._M_node
- 1) + (__x
._M_cur
- __x
._M_first
)
345 + (__y
._M_last
- __y
._M_cur
);
348 template<typename _Tp
, typename _Ref
, typename _Ptr
>
349 inline _Deque_iterator
<_Tp
, _Ref
, _Ptr
>
350 operator+(ptrdiff_t __n
, const _Deque_iterator
<_Tp
, _Ref
, _Ptr
>& __x
)
351 { return __x
+ __n
; }
353 template<typename _Tp
>
355 fill(const _Deque_iterator
<_Tp
, _Tp
&, _Tp
*>& __first
,
356 const _Deque_iterator
<_Tp
, _Tp
&, _Tp
*>& __last
, const _Tp
& __value
);
360 * Deque base class. This class provides the unified face for %deque's
361 * allocation. This class's constructor and destructor allocate and
362 * deallocate (but do not initialize) storage. This makes %exception
365 * Nothing in this class ever constructs or destroys an actual Tp element.
366 * (Deque handles that itself.) Only/All memory management is performed
370 template<typename _Tp
, typename _Alloc
>
374 typedef _Alloc allocator_type
;
377 get_allocator() const
378 { return allocator_type(_M_get_Tp_allocator()); }
380 typedef _Deque_iterator
<_Tp
, _Tp
&, _Tp
*> iterator
;
381 typedef _Deque_iterator
<_Tp
, const _Tp
&, const _Tp
*> const_iterator
;
383 _Deque_base(const allocator_type
& __a
, size_t __num_elements
)
385 { _M_initialize_map(__num_elements
); }
387 _Deque_base(const allocator_type
& __a
)
394 //This struct encapsulates the implementation of the std::deque
395 //standard container and at the same time makes use of the EBO
396 //for empty allocators.
397 typedef typename
_Alloc::template rebind
<_Tp
*>::other _Map_alloc_type
;
399 typedef typename
_Alloc::template rebind
<_Tp
>::other _Tp_alloc_type
;
402 : public _Tp_alloc_type
409 _Deque_impl(const _Tp_alloc_type
& __a
)
410 : _Tp_alloc_type(__a
), _M_map(0), _M_map_size(0),
411 _M_start(), _M_finish()
416 _M_get_Tp_allocator()
417 { return *static_cast<_Tp_alloc_type
*>(&this->_M_impl
); }
419 const _Tp_alloc_type
&
420 _M_get_Tp_allocator() const
421 { return *static_cast<const _Tp_alloc_type
*>(&this->_M_impl
); }
424 _M_get_map_allocator() const
425 { return _Map_alloc_type(_M_get_Tp_allocator()); }
430 return _M_impl
._Tp_alloc_type::allocate(__deque_buf_size(sizeof(_Tp
)));
434 _M_deallocate_node(_Tp
* __p
)
436 _M_impl
._Tp_alloc_type::deallocate(__p
, __deque_buf_size(sizeof(_Tp
)));
440 _M_allocate_map(size_t __n
)
441 { return _M_get_map_allocator().allocate(__n
); }
444 _M_deallocate_map(_Tp
** __p
, size_t __n
)
445 { _M_get_map_allocator().deallocate(__p
, __n
); }
448 void _M_initialize_map(size_t);
449 void _M_create_nodes(_Tp
** __nstart
, _Tp
** __nfinish
);
450 void _M_destroy_nodes(_Tp
** __nstart
, _Tp
** __nfinish
);
451 enum { _S_initial_map_size
= 8 };
456 template<typename _Tp
, typename _Alloc
>
457 _Deque_base
<_Tp
, _Alloc
>::
460 if (this->_M_impl
._M_map
)
462 _M_destroy_nodes(this->_M_impl
._M_start
._M_node
,
463 this->_M_impl
._M_finish
._M_node
+ 1);
464 _M_deallocate_map(this->_M_impl
._M_map
, this->_M_impl
._M_map_size
);
470 * @brief Layout storage.
471 * @param num_elements The count of T's for which to allocate space
475 * The initial underlying memory layout is a bit complicated...
478 template<typename _Tp
, typename _Alloc
>
480 _Deque_base
<_Tp
, _Alloc
>::
481 _M_initialize_map(size_t __num_elements
)
483 const size_t __num_nodes
= (__num_elements
/ __deque_buf_size(sizeof(_Tp
))
486 this->_M_impl
._M_map_size
= std::max((size_t) _S_initial_map_size
,
487 size_t(__num_nodes
+ 2));
488 this->_M_impl
._M_map
= _M_allocate_map(this->_M_impl
._M_map_size
);
490 // For "small" maps (needing less than _M_map_size nodes), allocation
491 // starts in the middle elements and grows outwards. So nstart may be
492 // the beginning of _M_map, but for small maps it may be as far in as
495 _Tp
** __nstart
= (this->_M_impl
._M_map
496 + (this->_M_impl
._M_map_size
- __num_nodes
) / 2);
497 _Tp
** __nfinish
= __nstart
+ __num_nodes
;
500 { _M_create_nodes(__nstart
, __nfinish
); }
503 _M_deallocate_map(this->_M_impl
._M_map
, this->_M_impl
._M_map_size
);
504 this->_M_impl
._M_map
= 0;
505 this->_M_impl
._M_map_size
= 0;
506 __throw_exception_again
;
509 this->_M_impl
._M_start
._M_set_node(__nstart
);
510 this->_M_impl
._M_finish
._M_set_node(__nfinish
- 1);
511 this->_M_impl
._M_start
._M_cur
= _M_impl
._M_start
._M_first
;
512 this->_M_impl
._M_finish
._M_cur
= (this->_M_impl
._M_finish
._M_first
514 % __deque_buf_size(sizeof(_Tp
)));
517 template<typename _Tp
, typename _Alloc
>
519 _Deque_base
<_Tp
, _Alloc
>::
520 _M_create_nodes(_Tp
** __nstart
, _Tp
** __nfinish
)
525 for (__cur
= __nstart
; __cur
< __nfinish
; ++__cur
)
526 *__cur
= this->_M_allocate_node();
530 _M_destroy_nodes(__nstart
, __cur
);
531 __throw_exception_again
;
535 template<typename _Tp
, typename _Alloc
>
537 _Deque_base
<_Tp
, _Alloc
>::
538 _M_destroy_nodes(_Tp
** __nstart
, _Tp
** __nfinish
)
540 for (_Tp
** __n
= __nstart
; __n
< __nfinish
; ++__n
)
541 _M_deallocate_node(*__n
);
545 * @brief A standard container using fixed-size memory allocation and
546 * constant-time manipulation of elements at either end.
548 * @ingroup Containers
551 * Meets the requirements of a <a href="tables.html#65">container</a>, a
552 * <a href="tables.html#66">reversible container</a>, and a
553 * <a href="tables.html#67">sequence</a>, including the
554 * <a href="tables.html#68">optional sequence requirements</a>.
556 * In previous HP/SGI versions of deque, there was an extra template
557 * parameter so users could control the node size. This extension turned
558 * out to violate the C++ standard (it can be detected using template
559 * template parameters), and it was removed.
562 * Here's how a deque<Tp> manages memory. Each deque has 4 members:
565 * - size_t _M_map_size
566 * - iterator _M_start, _M_finish
568 * map_size is at least 8. %map is an array of map_size
569 * pointers-to-"nodes". (The name %map has nothing to do with the
570 * std::map class, and "nodes" should not be confused with
571 * std::list's usage of "node".)
573 * A "node" has no specific type name as such, but it is referred
574 * to as "node" in this file. It is a simple array-of-Tp. If Tp
575 * is very large, there will be one Tp element per node (i.e., an
576 * "array" of one). For non-huge Tp's, node size is inversely
577 * related to Tp size: the larger the Tp, the fewer Tp's will fit
578 * in a node. The goal here is to keep the total size of a node
579 * relatively small and constant over different Tp's, to improve
580 * allocator efficiency.
582 * Not every pointer in the %map array will point to a node. If
583 * the initial number of elements in the deque is small, the
584 * /middle/ %map pointers will be valid, and the ones at the edges
585 * will be unused. This same situation will arise as the %map
586 * grows: available %map pointers, if any, will be on the ends. As
587 * new nodes are created, only a subset of the %map's pointers need
588 * to be copied "outward".
591 * - For any nonsingular iterator i:
592 * - i.node points to a member of the %map array. (Yes, you read that
593 * correctly: i.node does not actually point to a node.) The member of
594 * the %map array is what actually points to the node.
595 * - i.first == *(i.node) (This points to the node (first Tp element).)
596 * - i.last == i.first + node_size
597 * - i.cur is a pointer in the range [i.first, i.last). NOTE:
598 * the implication of this is that i.cur is always a dereferenceable
599 * pointer, even if i is a past-the-end iterator.
600 * - Start and Finish are always nonsingular iterators. NOTE: this
601 * means that an empty deque must have one node, a deque with <N
602 * elements (where N is the node buffer size) must have one node, a
603 * deque with N through (2N-1) elements must have two nodes, etc.
604 * - For every node other than start.node and finish.node, every
605 * element in the node is an initialized object. If start.node ==
606 * finish.node, then [start.cur, finish.cur) are initialized
607 * objects, and the elements outside that range are uninitialized
608 * storage. Otherwise, [start.cur, start.last) and [finish.first,
609 * finish.cur) are initialized objects, and [start.first, start.cur)
610 * and [finish.cur, finish.last) are uninitialized storage.
611 * - [%map, %map + map_size) is a valid, non-empty range.
612 * - [start.node, finish.node] is a valid range contained within
613 * [%map, %map + map_size).
614 * - A pointer in the range [%map, %map + map_size) points to an allocated
615 * node if and only if the pointer is in the range
616 * [start.node, finish.node].
618 * Here's the magic: nothing in deque is "aware" of the discontiguous
621 * The memory setup and layout occurs in the parent, _Base, and the iterator
622 * class is entirely responsible for "leaping" from one node to the next.
623 * All the implementation routines for deque itself work only through the
624 * start and finish iterators. This keeps the routines simple and sane,
625 * and we can use other standard algorithms as well.
628 template<typename _Tp
, typename _Alloc
= std::allocator
<_Tp
> >
629 class deque
: protected _Deque_base
<_Tp
, _Alloc
>
631 // concept requirements
632 typedef typename
_Alloc::value_type _Alloc_value_type
;
633 __glibcxx_class_requires(_Tp
, _SGIAssignableConcept
)
634 __glibcxx_class_requires2(_Tp
, _Alloc_value_type
, _SameTypeConcept
)
636 typedef _Deque_base
<_Tp
, _Alloc
> _Base
;
637 typedef typename
_Base::_Tp_alloc_type _Tp_alloc_type
;
640 typedef _Tp value_type
;
641 typedef typename
_Tp_alloc_type::pointer pointer
;
642 typedef typename
_Tp_alloc_type::const_pointer const_pointer
;
643 typedef typename
_Tp_alloc_type::reference reference
;
644 typedef typename
_Tp_alloc_type::const_reference const_reference
;
645 typedef typename
_Base::iterator iterator
;
646 typedef typename
_Base::const_iterator const_iterator
;
647 typedef std::reverse_iterator
<const_iterator
> const_reverse_iterator
;
648 typedef std::reverse_iterator
<iterator
> reverse_iterator
;
649 typedef size_t size_type
;
650 typedef ptrdiff_t difference_type
;
651 typedef _Alloc allocator_type
;
654 typedef pointer
* _Map_pointer
;
656 static size_t _S_buffer_size()
657 { return __deque_buf_size(sizeof(_Tp
)); }
659 // Functions controlling memory layout, and nothing else.
660 using _Base::_M_initialize_map
;
661 using _Base::_M_create_nodes
;
662 using _Base::_M_destroy_nodes
;
663 using _Base::_M_allocate_node
;
664 using _Base::_M_deallocate_node
;
665 using _Base::_M_allocate_map
;
666 using _Base::_M_deallocate_map
;
667 using _Base::_M_get_Tp_allocator
;
670 * A total of four data members accumulated down the heirarchy.
671 * May be accessed via _M_impl.*
674 using _Base::_M_impl
;
677 // [23.2.1.1] construct/copy/destroy
678 // (assign() and get_allocator() are also listed in this section)
680 * @brief Default constructor creates no elements.
683 deque(const allocator_type
& __a
= allocator_type())
687 * @brief Create a %deque with copies of an exemplar element.
688 * @param n The number of elements to initially create.
689 * @param value An element to copy.
691 * This constructor fills the %deque with @a n copies of @a value.
694 deque(size_type __n
, const value_type
& __value
= value_type(),
695 const allocator_type
& __a
= allocator_type())
697 { _M_fill_initialize(__value
); }
700 * @brief %Deque copy constructor.
701 * @param x A %deque of identical element and allocator types.
703 * The newly-created %deque uses a copy of the allocation object used
706 deque(const deque
& __x
)
707 : _Base(__x
._M_get_Tp_allocator(), __x
.size())
708 { std::__uninitialized_copy_a(__x
.begin(), __x
.end(),
709 this->_M_impl
._M_start
,
710 _M_get_Tp_allocator()); }
713 * @brief Builds a %deque from a range.
714 * @param first An input iterator.
715 * @param last An input iterator.
717 * Create a %deque consisting of copies of the elements from [first,
720 * If the iterators are forward, bidirectional, or random-access, then
721 * this will call the elements' copy constructor N times (where N is
722 * distance(first,last)) and do no memory reallocation. But if only
723 * input iterators are used, then this will do at most 2N calls to the
724 * copy constructor, and logN memory reallocations.
726 template<typename _InputIterator
>
727 deque(_InputIterator __first
, _InputIterator __last
,
728 const allocator_type
& __a
= allocator_type())
731 // Check whether it's an integral type. If so, it's not an iterator.
732 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
733 _M_initialize_dispatch(__first
, __last
, _Integral());
737 * The dtor only erases the elements, and note that if the elements
738 * themselves are pointers, the pointed-to memory is not touched in any
739 * way. Managing the pointer is the user's responsibilty.
742 { _M_destroy_data(begin(), end(), _M_get_Tp_allocator()); }
745 * @brief %Deque assignment operator.
746 * @param x A %deque of identical element and allocator types.
748 * All the elements of @a x are copied, but unlike the copy constructor,
749 * the allocator object is not copied.
752 operator=(const deque
& __x
);
755 * @brief Assigns a given value to a %deque.
756 * @param n Number of elements to be assigned.
757 * @param val Value to be assigned.
759 * This function fills a %deque with @a n copies of the given
760 * value. Note that the assignment completely changes the
761 * %deque and that the resulting %deque's size is the same as
762 * the number of elements assigned. Old data may be lost.
765 assign(size_type __n
, const value_type
& __val
)
766 { _M_fill_assign(__n
, __val
); }
769 * @brief Assigns a range to a %deque.
770 * @param first An input iterator.
771 * @param last An input iterator.
773 * This function fills a %deque with copies of the elements in the
774 * range [first,last).
776 * Note that the assignment completely changes the %deque and that the
777 * resulting %deque's size is the same as the number of elements
778 * assigned. Old data may be lost.
780 template<typename _InputIterator
>
782 assign(_InputIterator __first
, _InputIterator __last
)
784 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
785 _M_assign_dispatch(__first
, __last
, _Integral());
788 /// Get a copy of the memory allocation object.
790 get_allocator() const
791 { return _Base::get_allocator(); }
795 * Returns a read/write iterator that points to the first element in the
796 * %deque. Iteration is done in ordinary element order.
800 { return this->_M_impl
._M_start
; }
803 * Returns a read-only (constant) iterator that points to the first
804 * element in the %deque. Iteration is done in ordinary element order.
808 { return this->_M_impl
._M_start
; }
811 * Returns a read/write iterator that points one past the last
812 * element in the %deque. Iteration is done in ordinary
817 { return this->_M_impl
._M_finish
; }
820 * Returns a read-only (constant) iterator that points one past
821 * the last element in the %deque. Iteration is done in
822 * ordinary element order.
826 { return this->_M_impl
._M_finish
; }
829 * Returns a read/write reverse iterator that points to the
830 * last element in the %deque. Iteration is done in reverse
835 { return reverse_iterator(this->_M_impl
._M_finish
); }
838 * Returns a read-only (constant) reverse iterator that points
839 * to the last element in the %deque. Iteration is done in
840 * reverse element order.
842 const_reverse_iterator
844 { return const_reverse_iterator(this->_M_impl
._M_finish
); }
847 * Returns a read/write reverse iterator that points to one
848 * before the first element in the %deque. Iteration is done
849 * in reverse element order.
853 { return reverse_iterator(this->_M_impl
._M_start
); }
856 * Returns a read-only (constant) reverse iterator that points
857 * to one before the first element in the %deque. Iteration is
858 * done in reverse element order.
860 const_reverse_iterator
862 { return const_reverse_iterator(this->_M_impl
._M_start
); }
864 // [23.2.1.2] capacity
865 /** Returns the number of elements in the %deque. */
868 { return this->_M_impl
._M_finish
- this->_M_impl
._M_start
; }
870 /** Returns the size() of the largest possible %deque. */
873 { return _M_get_Tp_allocator().max_size(); }
876 * @brief Resizes the %deque to the specified number of elements.
877 * @param new_size Number of elements the %deque should contain.
878 * @param x Data with which new elements should be populated.
880 * This function will %resize the %deque to the specified
881 * number of elements. If the number is smaller than the
882 * %deque's current size the %deque is truncated, otherwise the
883 * %deque is extended and new elements are populated with given
887 resize(size_type __new_size
, value_type __x
= value_type())
889 const size_type __len
= size();
890 if (__new_size
< __len
)
891 _M_erase_at_end(this->_M_impl
._M_start
+ difference_type(__new_size
));
893 insert(this->_M_impl
._M_finish
, __new_size
- __len
, __x
);
897 * Returns true if the %deque is empty. (Thus begin() would
902 { return this->_M_impl
._M_finish
== this->_M_impl
._M_start
; }
906 * @brief Subscript access to the data contained in the %deque.
907 * @param n The index of the element for which data should be
909 * @return Read/write reference to data.
911 * This operator allows for easy, array-style, data access.
912 * Note that data access with this operator is unchecked and
913 * out_of_range lookups are not defined. (For checked lookups
917 operator[](size_type __n
)
918 { return this->_M_impl
._M_start
[difference_type(__n
)]; }
921 * @brief Subscript access to the data contained in the %deque.
922 * @param n The index of the element for which data should be
924 * @return Read-only (constant) reference to data.
926 * This operator allows for easy, array-style, data access.
927 * Note that data access with this operator is unchecked and
928 * out_of_range lookups are not defined. (For checked lookups
932 operator[](size_type __n
) const
933 { return this->_M_impl
._M_start
[difference_type(__n
)]; }
936 /// @if maint Safety check used only from at(). @endif
938 _M_range_check(size_type __n
) const
940 if (__n
>= this->size())
941 __throw_out_of_range(__N("deque::_M_range_check"));
946 * @brief Provides access to the data contained in the %deque.
947 * @param n The index of the element for which data should be
949 * @return Read/write reference to data.
950 * @throw std::out_of_range If @a n is an invalid index.
952 * This function provides for safer data access. The parameter
953 * is first checked that it is in the range of the deque. The
954 * function throws out_of_range if the check fails.
964 * @brief Provides access to the data contained in the %deque.
965 * @param n The index of the element for which data should be
967 * @return Read-only (constant) reference to data.
968 * @throw std::out_of_range If @a n is an invalid index.
970 * This function provides for safer data access. The parameter is first
971 * checked that it is in the range of the deque. The function throws
972 * out_of_range if the check fails.
975 at(size_type __n
) const
982 * Returns a read/write reference to the data at the first
983 * element of the %deque.
990 * Returns a read-only (constant) reference to the data at the first
991 * element of the %deque.
998 * Returns a read/write reference to the data at the last element of the
1004 iterator __tmp
= end();
1010 * Returns a read-only (constant) reference to the data at the last
1011 * element of the %deque.
1016 const_iterator __tmp
= end();
1021 // [23.2.1.2] modifiers
1023 * @brief Add data to the front of the %deque.
1024 * @param x Data to be added.
1026 * This is a typical stack operation. The function creates an
1027 * element at the front of the %deque and assigns the given
1028 * data to it. Due to the nature of a %deque this operation
1029 * can be done in constant time.
1032 push_front(const value_type
& __x
)
1034 if (this->_M_impl
._M_start
._M_cur
!= this->_M_impl
._M_start
._M_first
)
1036 this->_M_impl
.construct(this->_M_impl
._M_start
._M_cur
- 1, __x
);
1037 --this->_M_impl
._M_start
._M_cur
;
1040 _M_push_front_aux(__x
);
1044 * @brief Add data to the end of the %deque.
1045 * @param x Data to be added.
1047 * This is a typical stack operation. The function creates an
1048 * element at the end of the %deque and assigns the given data
1049 * to it. Due to the nature of a %deque this operation can be
1050 * done in constant time.
1053 push_back(const value_type
& __x
)
1055 if (this->_M_impl
._M_finish
._M_cur
1056 != this->_M_impl
._M_finish
._M_last
- 1)
1058 this->_M_impl
.construct(this->_M_impl
._M_finish
._M_cur
, __x
);
1059 ++this->_M_impl
._M_finish
._M_cur
;
1062 _M_push_back_aux(__x
);
1066 * @brief Removes first element.
1068 * This is a typical stack operation. It shrinks the %deque by one.
1070 * Note that no data is returned, and if the first element's data is
1071 * needed, it should be retrieved before pop_front() is called.
1076 if (this->_M_impl
._M_start
._M_cur
1077 != this->_M_impl
._M_start
._M_last
- 1)
1079 this->_M_impl
.destroy(this->_M_impl
._M_start
._M_cur
);
1080 ++this->_M_impl
._M_start
._M_cur
;
1087 * @brief Removes last element.
1089 * This is a typical stack operation. It shrinks the %deque by one.
1091 * Note that no data is returned, and if the last element's data is
1092 * needed, it should be retrieved before pop_back() is called.
1097 if (this->_M_impl
._M_finish
._M_cur
1098 != this->_M_impl
._M_finish
._M_first
)
1100 --this->_M_impl
._M_finish
._M_cur
;
1101 this->_M_impl
.destroy(this->_M_impl
._M_finish
._M_cur
);
1108 * @brief Inserts given value into %deque before specified iterator.
1109 * @param position An iterator into the %deque.
1110 * @param x Data to be inserted.
1111 * @return An iterator that points to the inserted data.
1113 * This function will insert a copy of the given value before the
1114 * specified location.
1117 insert(iterator __position
, const value_type
& __x
);
1120 * @brief Inserts a number of copies of given data into the %deque.
1121 * @param position An iterator into the %deque.
1122 * @param n Number of elements to be inserted.
1123 * @param x Data to be inserted.
1125 * This function will insert a specified number of copies of the given
1126 * data before the location specified by @a position.
1129 insert(iterator __position
, size_type __n
, const value_type
& __x
)
1130 { _M_fill_insert(__position
, __n
, __x
); }
1133 * @brief Inserts a range into the %deque.
1134 * @param position An iterator into the %deque.
1135 * @param first An input iterator.
1136 * @param last An input iterator.
1138 * This function will insert copies of the data in the range
1139 * [first,last) into the %deque before the location specified
1140 * by @a pos. This is known as "range insert."
1142 template<typename _InputIterator
>
1144 insert(iterator __position
, _InputIterator __first
,
1145 _InputIterator __last
)
1147 // Check whether it's an integral type. If so, it's not an iterator.
1148 typedef typename
std::__is_integer
<_InputIterator
>::__type _Integral
;
1149 _M_insert_dispatch(__position
, __first
, __last
, _Integral());
1153 * @brief Remove element at given position.
1154 * @param position Iterator pointing to element to be erased.
1155 * @return An iterator pointing to the next element (or end()).
1157 * This function will erase the element at the given position and thus
1158 * shorten the %deque by one.
1160 * The user is cautioned that
1161 * this function only erases the element, and that if the element is
1162 * itself a pointer, the pointed-to memory is not touched in any way.
1163 * Managing the pointer is the user's responsibilty.
1166 erase(iterator __position
);
1169 * @brief Remove a range of elements.
1170 * @param first Iterator pointing to the first element to be erased.
1171 * @param last Iterator pointing to one past the last element to be
1173 * @return An iterator pointing to the element pointed to by @a last
1174 * prior to erasing (or end()).
1176 * This function will erase the elements in the range [first,last) and
1177 * shorten the %deque accordingly.
1179 * The user is cautioned that
1180 * this function only erases the elements, and that if the elements
1181 * themselves are pointers, the pointed-to memory is not touched in any
1182 * way. Managing the pointer is the user's responsibilty.
1185 erase(iterator __first
, iterator __last
);
1188 * @brief Swaps data with another %deque.
1189 * @param x A %deque of the same element and allocator types.
1191 * This exchanges the elements between two deques in constant time.
1192 * (Four pointers, so it should be quite fast.)
1193 * Note that the global std::swap() function is specialized such that
1194 * std::swap(d1,d2) will feed to this function.
1199 std::swap(this->_M_impl
._M_start
, __x
._M_impl
._M_start
);
1200 std::swap(this->_M_impl
._M_finish
, __x
._M_impl
._M_finish
);
1201 std::swap(this->_M_impl
._M_map
, __x
._M_impl
._M_map
);
1202 std::swap(this->_M_impl
._M_map_size
, __x
._M_impl
._M_map_size
);
1204 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1205 // 431. Swapping containers with unequal allocators.
1206 std::__alloc_swap
<_Tp_alloc_type
>::_S_do_it(_M_get_Tp_allocator(),
1207 __x
._M_get_Tp_allocator());
1211 * Erases all the elements. Note that this function only erases the
1212 * elements, and that if the elements themselves are pointers, the
1213 * pointed-to memory is not touched in any way. Managing the pointer is
1214 * the user's responsibilty.
1218 { _M_erase_at_end(begin()); }
1221 // Internal constructor functions follow.
1223 // called by the range constructor to implement [23.1.1]/9
1225 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1226 // 438. Ambiguity in the "do the right thing" clause
1227 template<typename _Integer
>
1229 _M_initialize_dispatch(_Integer __n
, _Integer __x
, __true_type
)
1231 _M_initialize_map(static_cast<size_type
>(__n
));
1232 _M_fill_initialize(__x
);
1235 // called by the range constructor to implement [23.1.1]/9
1236 template<typename _InputIterator
>
1238 _M_initialize_dispatch(_InputIterator __first
, _InputIterator __last
,
1241 typedef typename
std::iterator_traits
<_InputIterator
>::
1242 iterator_category _IterCategory
;
1243 _M_range_initialize(__first
, __last
, _IterCategory());
1246 // called by the second initialize_dispatch above
1250 * @brief Fills the deque with whatever is in [first,last).
1251 * @param first An input iterator.
1252 * @param last An input iterator.
1255 * If the iterators are actually forward iterators (or better), then the
1256 * memory layout can be done all at once. Else we move forward using
1257 * push_back on each value from the iterator.
1260 template<typename _InputIterator
>
1262 _M_range_initialize(_InputIterator __first
, _InputIterator __last
,
1263 std::input_iterator_tag
);
1265 // called by the second initialize_dispatch above
1266 template<typename _ForwardIterator
>
1268 _M_range_initialize(_ForwardIterator __first
, _ForwardIterator __last
,
1269 std::forward_iterator_tag
);
1274 * @brief Fills the %deque with copies of value.
1275 * @param value Initial value.
1277 * @pre _M_start and _M_finish have already been initialized,
1278 * but none of the %deque's elements have yet been constructed.
1280 * This function is called only when the user provides an explicit size
1281 * (with or without an explicit exemplar value).
1285 _M_fill_initialize(const value_type
& __value
);
1287 // Internal assign functions follow. The *_aux functions do the actual
1288 // assignment work for the range versions.
1290 // called by the range assign to implement [23.1.1]/9
1292 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1293 // 438. Ambiguity in the "do the right thing" clause
1294 template<typename _Integer
>
1296 _M_assign_dispatch(_Integer __n
, _Integer __val
, __true_type
)
1297 { _M_fill_assign(__n
, __val
); }
1299 // called by the range assign to implement [23.1.1]/9
1300 template<typename _InputIterator
>
1302 _M_assign_dispatch(_InputIterator __first
, _InputIterator __last
,
1305 typedef typename
std::iterator_traits
<_InputIterator
>::
1306 iterator_category _IterCategory
;
1307 _M_assign_aux(__first
, __last
, _IterCategory());
1310 // called by the second assign_dispatch above
1311 template<typename _InputIterator
>
1313 _M_assign_aux(_InputIterator __first
, _InputIterator __last
,
1314 std::input_iterator_tag
);
1316 // called by the second assign_dispatch above
1317 template<typename _ForwardIterator
>
1319 _M_assign_aux(_ForwardIterator __first
, _ForwardIterator __last
,
1320 std::forward_iterator_tag
)
1322 const size_type __len
= std::distance(__first
, __last
);
1325 _ForwardIterator __mid
= __first
;
1326 std::advance(__mid
, size());
1327 std::copy(__first
, __mid
, begin());
1328 insert(end(), __mid
, __last
);
1331 _M_erase_at_end(std::copy(__first
, __last
, begin()));
1334 // Called by assign(n,t), and the range assign when it turns out
1335 // to be the same thing.
1337 _M_fill_assign(size_type __n
, const value_type
& __val
)
1341 std::fill(begin(), end(), __val
);
1342 insert(end(), __n
- size(), __val
);
1346 _M_erase_at_end(begin() + difference_type(__n
));
1347 std::fill(begin(), end(), __val
);
1354 * @brief Helper functions for push_* and pop_*.
1357 void _M_push_back_aux(const value_type
&);
1359 void _M_push_front_aux(const value_type
&);
1361 void _M_pop_back_aux();
1363 void _M_pop_front_aux();
1366 // Internal insert functions follow. The *_aux functions do the actual
1367 // insertion work when all shortcuts fail.
1369 // called by the range insert to implement [23.1.1]/9
1371 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1372 // 438. Ambiguity in the "do the right thing" clause
1373 template<typename _Integer
>
1375 _M_insert_dispatch(iterator __pos
,
1376 _Integer __n
, _Integer __x
, __true_type
)
1377 { _M_fill_insert(__pos
, __n
, __x
); }
1379 // called by the range insert to implement [23.1.1]/9
1380 template<typename _InputIterator
>
1382 _M_insert_dispatch(iterator __pos
,
1383 _InputIterator __first
, _InputIterator __last
,
1386 typedef typename
std::iterator_traits
<_InputIterator
>::
1387 iterator_category _IterCategory
;
1388 _M_range_insert_aux(__pos
, __first
, __last
, _IterCategory());
1391 // called by the second insert_dispatch above
1392 template<typename _InputIterator
>
1394 _M_range_insert_aux(iterator __pos
, _InputIterator __first
,
1395 _InputIterator __last
, std::input_iterator_tag
);
1397 // called by the second insert_dispatch above
1398 template<typename _ForwardIterator
>
1400 _M_range_insert_aux(iterator __pos
, _ForwardIterator __first
,
1401 _ForwardIterator __last
, std::forward_iterator_tag
);
1403 // Called by insert(p,n,x), and the range insert when it turns out to be
1404 // the same thing. Can use fill functions in optimal situations,
1405 // otherwise passes off to insert_aux(p,n,x).
1407 _M_fill_insert(iterator __pos
, size_type __n
, const value_type
& __x
);
1409 // called by insert(p,x)
1411 _M_insert_aux(iterator __pos
, const value_type
& __x
);
1413 // called by insert(p,n,x) via fill_insert
1415 _M_insert_aux(iterator __pos
, size_type __n
, const value_type
& __x
);
1417 // called by range_insert_aux for forward iterators
1418 template<typename _ForwardIterator
>
1420 _M_insert_aux(iterator __pos
,
1421 _ForwardIterator __first
, _ForwardIterator __last
,
1425 // Internal erase functions follow.
1428 _M_destroy_data_aux(iterator __first
, iterator __last
);
1430 // Called by ~deque().
1431 // NB: Doesn't deallocate the nodes.
1432 template<typename _Alloc1
>
1434 _M_destroy_data(iterator __first
, iterator __last
, const _Alloc1
&)
1435 { _M_destroy_data_aux(__first
, __last
); }
1438 _M_destroy_data(iterator __first
, iterator __last
,
1439 const std::allocator
<_Tp
>&)
1441 if (!__has_trivial_destructor(value_type
))
1442 _M_destroy_data_aux(__first
, __last
);
1445 // Called by erase(q1, q2).
1447 _M_erase_at_begin(iterator __pos
)
1449 _M_destroy_data(begin(), __pos
, _M_get_Tp_allocator());
1450 _M_destroy_nodes(this->_M_impl
._M_start
._M_node
, __pos
._M_node
);
1451 this->_M_impl
._M_start
= __pos
;
1454 // Called by erase(q1, q2), resize(), clear(), _M_assign_aux,
1455 // _M_fill_assign, operator=.
1457 _M_erase_at_end(iterator __pos
)
1459 _M_destroy_data(__pos
, end(), _M_get_Tp_allocator());
1460 _M_destroy_nodes(__pos
._M_node
+ 1,
1461 this->_M_impl
._M_finish
._M_node
+ 1);
1462 this->_M_impl
._M_finish
= __pos
;
1468 * @brief Memory-handling helpers for the previous internal insert
1473 _M_reserve_elements_at_front(size_type __n
)
1475 const size_type __vacancies
= this->_M_impl
._M_start
._M_cur
1476 - this->_M_impl
._M_start
._M_first
;
1477 if (__n
> __vacancies
)
1478 _M_new_elements_at_front(__n
- __vacancies
);
1479 return this->_M_impl
._M_start
- difference_type(__n
);
1483 _M_reserve_elements_at_back(size_type __n
)
1485 const size_type __vacancies
= (this->_M_impl
._M_finish
._M_last
1486 - this->_M_impl
._M_finish
._M_cur
) - 1;
1487 if (__n
> __vacancies
)
1488 _M_new_elements_at_back(__n
- __vacancies
);
1489 return this->_M_impl
._M_finish
+ difference_type(__n
);
1493 _M_new_elements_at_front(size_type __new_elements
);
1496 _M_new_elements_at_back(size_type __new_elements
);
1503 * @brief Memory-handling helpers for the major %map.
1505 * Makes sure the _M_map has space for new nodes. Does not
1506 * actually add the nodes. Can invalidate _M_map pointers.
1507 * (And consequently, %deque iterators.)
1511 _M_reserve_map_at_back(size_type __nodes_to_add
= 1)
1513 if (__nodes_to_add
+ 1 > this->_M_impl
._M_map_size
1514 - (this->_M_impl
._M_finish
._M_node
- this->_M_impl
._M_map
))
1515 _M_reallocate_map(__nodes_to_add
, false);
1519 _M_reserve_map_at_front(size_type __nodes_to_add
= 1)
1521 if (__nodes_to_add
> size_type(this->_M_impl
._M_start
._M_node
1522 - this->_M_impl
._M_map
))
1523 _M_reallocate_map(__nodes_to_add
, true);
1527 _M_reallocate_map(size_type __nodes_to_add
, bool __add_at_front
);
1533 * @brief Deque equality comparison.
1534 * @param x A %deque.
1535 * @param y A %deque of the same type as @a x.
1536 * @return True iff the size and elements of the deques are equal.
1538 * This is an equivalence relation. It is linear in the size of the
1539 * deques. Deques are considered equivalent if their sizes are equal,
1540 * and if corresponding elements compare equal.
1542 template<typename _Tp
, typename _Alloc
>
1544 operator==(const deque
<_Tp
, _Alloc
>& __x
,
1545 const deque
<_Tp
, _Alloc
>& __y
)
1546 { return __x
.size() == __y
.size()
1547 && std::equal(__x
.begin(), __x
.end(), __y
.begin()); }
1550 * @brief Deque ordering relation.
1551 * @param x A %deque.
1552 * @param y A %deque of the same type as @a x.
1553 * @return True iff @a x is lexicographically less than @a y.
1555 * This is a total ordering relation. It is linear in the size of the
1556 * deques. The elements must be comparable with @c <.
1558 * See std::lexicographical_compare() for how the determination is made.
1560 template<typename _Tp
, typename _Alloc
>
1562 operator<(const deque
<_Tp
, _Alloc
>& __x
,
1563 const deque
<_Tp
, _Alloc
>& __y
)
1564 { return std::lexicographical_compare(__x
.begin(), __x
.end(),
1565 __y
.begin(), __y
.end()); }
1567 /// Based on operator==
1568 template<typename _Tp
, typename _Alloc
>
1570 operator!=(const deque
<_Tp
, _Alloc
>& __x
,
1571 const deque
<_Tp
, _Alloc
>& __y
)
1572 { return !(__x
== __y
); }
1574 /// Based on operator<
1575 template<typename _Tp
, typename _Alloc
>
1577 operator>(const deque
<_Tp
, _Alloc
>& __x
,
1578 const deque
<_Tp
, _Alloc
>& __y
)
1579 { return __y
< __x
; }
1581 /// Based on operator<
1582 template<typename _Tp
, typename _Alloc
>
1584 operator<=(const deque
<_Tp
, _Alloc
>& __x
,
1585 const deque
<_Tp
, _Alloc
>& __y
)
1586 { return !(__y
< __x
); }
1588 /// Based on operator<
1589 template<typename _Tp
, typename _Alloc
>
1591 operator>=(const deque
<_Tp
, _Alloc
>& __x
,
1592 const deque
<_Tp
, _Alloc
>& __y
)
1593 { return !(__x
< __y
); }
1595 /// See std::deque::swap().
1596 template<typename _Tp
, typename _Alloc
>
1598 swap(deque
<_Tp
,_Alloc
>& __x
, deque
<_Tp
,_Alloc
>& __y
)
1601 _GLIBCXX_END_NESTED_NAMESPACE
1603 #endif /* _STL_DEQUE_H */