57 #define _STL_QUEUE_H 1 61 #if __cplusplus >= 201103L 62 # include <bits/uses_allocator.h> 65 namespace std _GLIBCXX_VISIBILITY(default)
67 _GLIBCXX_BEGIN_NAMESPACE_VERSION
95 template<
typename _Tp,
typename _Sequence = deque<_Tp> >
99 typedef typename _Sequence::value_type _Sequence_value_type;
100 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
101 __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
102 __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
103 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
105 template<
typename _Tp1,
typename _Seq1>
109 template<
typename _Tp1,
typename _Seq1>
113 #if __cplusplus >= 201103L 114 template<
typename _Alloc>
115 using _Uses =
typename 116 enable_if<uses_allocator<_Sequence, _Alloc>::value>::type;
120 typedef typename _Sequence::value_type value_type;
121 typedef typename _Sequence::reference reference;
122 typedef typename _Sequence::const_reference const_reference;
123 typedef typename _Sequence::size_type size_type;
124 typedef _Sequence container_type;
141 #if __cplusplus < 201103L 143 queue(
const _Sequence& __c = _Sequence())
151 queue(_Sequence&& __c = _Sequence())
152 :
c(std::move(__c)) { }
154 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
156 queue(
const _Alloc& __a)
159 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
160 queue(
const _Sequence& __c,
const _Alloc& __a)
163 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
164 queue(_Sequence&& __c,
const _Alloc& __a)
165 :
c(std::move(__c), __a) { }
167 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
171 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
173 :
c(std::move(__q.
c), __a) { }
181 {
return c.empty(); }
195 __glibcxx_requires_nonempty();
206 __glibcxx_requires_nonempty();
217 __glibcxx_requires_nonempty();
228 __glibcxx_requires_nonempty();
243 { c.push_back(__x); }
245 #if __cplusplus >= 201103L 247 push(value_type&& __x)
248 { c.push_back(std::move(__x)); }
250 template<
typename... _Args>
252 emplace(_Args&&... __args)
253 { c.emplace_back(std::forward<_Args>(__args)...); }
270 __glibcxx_requires_nonempty();
274 #if __cplusplus >= 201103L 277 noexcept(__is_nothrow_swappable<_Tp>::value)
296 template<
typename _Tp,
typename _Seq>
299 {
return __x.
c == __y.
c; }
314 template<
typename _Tp,
typename _Seq>
317 {
return __x.
c < __y.c; }
320 template<
typename _Tp,
typename _Seq>
323 {
return !(__x == __y); }
326 template<
typename _Tp,
typename _Seq>
329 {
return __y < __x; }
332 template<
typename _Tp,
typename _Seq>
335 {
return !(__y < __x); }
338 template<
typename _Tp,
typename _Seq>
341 {
return !(__x < __y); }
343 #if __cplusplus >= 201103L 344 template<
typename _Tp,
typename _Seq>
347 noexcept(noexcept(__x.swap(__y)))
350 template<
typename _Tp,
typename _Seq,
typename _Alloc>
395 template<
typename _Tp,
typename _Sequence = vector<_Tp>,
396 typename _Compare = less<
typename _Sequence::value_type> >
400 typedef typename _Sequence::value_type _Sequence_value_type;
401 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
402 __glibcxx_class_requires(_Sequence, _SequenceConcept)
403 __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
404 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
405 __glibcxx_class_requires4(_Compare,
bool, _Tp, _Tp,
406 _BinaryFunctionConcept)
408 #if __cplusplus >= 201103L 409 template<
typename _Alloc>
410 using _Uses =
typename 411 enable_if<uses_allocator<_Sequence, _Alloc>::value>::type;
415 typedef typename _Sequence::value_type value_type;
416 typedef typename _Sequence::reference reference;
417 typedef typename _Sequence::const_reference const_reference;
418 typedef typename _Sequence::size_type size_type;
419 typedef _Sequence container_type;
430 #if __cplusplus < 201103L 433 const _Sequence& __s = _Sequence())
439 const _Sequence& __s)
445 _Sequence&& __s = _Sequence())
446 :
c(std::move(__s)), comp(__x)
449 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
451 priority_queue(
const _Alloc& __a)
454 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
455 priority_queue(
const _Compare& __x,
const _Alloc& __a)
456 :
c(__a), comp(__x) { }
458 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
459 priority_queue(
const _Compare& __x,
const _Sequence& __c,
461 :
c(__c, __a), comp(__x) { }
463 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
464 priority_queue(
const _Compare& __x, _Sequence&& __c,
const _Alloc& __a)
465 :
c(std::move(__c), __a), comp(__x) { }
467 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
468 priority_queue(
const priority_queue& __q,
const _Alloc& __a)
469 :
c(__q.c, __a), comp(__q.comp) { }
471 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
472 priority_queue(priority_queue&& __q,
const _Alloc& __a)
473 :
c(std::move(__q.c), __a), comp(std::move(__q.comp)) { }
491 #if __cplusplus < 201103L 492 template<
typename _InputIterator>
493 priority_queue(_InputIterator __first, _InputIterator __last,
494 const _Compare& __x = _Compare(),
495 const _Sequence& __s = _Sequence())
498 __glibcxx_requires_valid_range(__first, __last);
499 c.insert(c.end(), __first, __last);
503 template<
typename _InputIterator>
506 const _Sequence& __s)
509 __glibcxx_requires_valid_range(__first, __last);
510 c.insert(c.end(), __first, __last);
514 template<
typename _InputIterator>
515 priority_queue(_InputIterator __first, _InputIterator __last,
516 const _Compare& __x = _Compare(),
517 _Sequence&& __s = _Sequence())
518 :
c(std::move(__s)), comp(__x)
520 __glibcxx_requires_valid_range(__first, __last);
521 c.insert(c.end(), __first, __last);
531 {
return c.empty(); }
545 __glibcxx_requires_nonempty();
564 #if __cplusplus >= 201103L 566 push(value_type&& __x)
568 c.push_back(std::move(__x));
572 template<
typename... _Args>
574 emplace(_Args&&... __args)
576 c.emplace_back(std::forward<_Args>(__args)...);
595 __glibcxx_requires_nonempty();
600 #if __cplusplus >= 201103L 602 swap(priority_queue& __pq)
603 noexcept(__is_nothrow_swappable<_Tp>::value
604 && __is_nothrow_swappable<_Compare>::value)
608 swap(comp, __pq.comp);
615 #if __cplusplus >= 201103L 616 template<
typename _Tp,
typename _Sequence,
typename _Compare>
620 noexcept(noexcept(__x.swap(__y)))
623 template<
typename _Tp,
typename _Sequence,
typename _Compare,
625 struct uses_allocator<priority_queue<_Tp, _Sequence, _Compare>, _Alloc>
629 _GLIBCXX_END_NAMESPACE_VERSION
const_reference top() const
void pop()
Removes first element.
const_reference back() const
A standard container automatically sorting its contents.
void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Pop an element off a heap using comparison functor.
void push(const value_type &__x)
Add data to the end of the queue.
void push(const value_type &__x)
Add data to the queue.
void pop()
Removes first element.
void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Push an element onto a heap using comparison functor.
const_reference front() const
priority_queue(const _Compare &__x, const _Sequence &__s)
Default constructor creates no elements.
priority_queue(_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s)
Builds a queue from a range.
void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp)
Construct a heap over a range using comparison functor.
ISO C++ entities toplevel namespace is std.
A standard container giving FIFO behavior.
Declare uses_allocator so it can be specialized in <queue> etc.
queue(const _Sequence &__c)
Default constructor creates no elements.