61#if __cplusplus >= 201103L
62# include <bits/uses_allocator.h>
65namespace std _GLIBCXX_VISIBILITY(default)
67_GLIBCXX_BEGIN_NAMESPACE_VERSION
95 template<
typename _Tp,
typename _Sequence = deque<_Tp> >
98#ifdef _GLIBCXX_CONCEPT_CHECKS
100 typedef typename _Sequence::value_type _Sequence_value_type;
101# if __cplusplus < 201103L
102 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
104 __glibcxx_class_requires(_Sequence, _FrontInsertionSequenceConcept)
105 __glibcxx_class_requires(_Sequence, _BackInsertionSequenceConcept)
106 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
109 template<
typename _Tp1,
typename _Seq1>
113 template<
typename _Tp1,
typename _Seq1>
117#if __cpp_lib_three_way_comparison
118 template<
typename _Tp1, three_way_comparable _Seq1>
119 friend compare_three_way_result_t<_Seq1>
123#if __cplusplus >= 201103L
124 template<
typename _Alloc>
125 using _Uses =
typename
128#if __cplusplus >= 201703L
133 "value_type must be the same as the underlying container");
138 typedef typename _Sequence::value_type value_type;
139 typedef typename _Sequence::reference reference;
140 typedef typename _Sequence::const_reference const_reference;
141 typedef typename _Sequence::size_type size_type;
142 typedef _Sequence container_type;
159#if __cplusplus < 201103L
161 queue(
const _Sequence& __c = _Sequence())
164 template<
typename _Seq = _Sequence,
typename _Requires =
typename
170 queue(
const _Sequence& __c)
174 queue(_Sequence&& __c)
177 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
179 queue(
const _Alloc& __a)
182 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
183 queue(
const _Sequence& __c,
const _Alloc& __a)
186 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
187 queue(_Sequence&& __c,
const _Alloc& __a)
190 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
194 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
202 _GLIBCXX_NODISCARD
bool
204 {
return c.empty(); }
218 __glibcxx_requires_nonempty();
229 __glibcxx_requires_nonempty();
240 __glibcxx_requires_nonempty();
251 __glibcxx_requires_nonempty();
266 {
c.push_back(__x); }
268#if __cplusplus >= 201103L
270 push(value_type&& __x)
273#if __cplusplus > 201402L
274 template<
typename... _Args>
276 emplace(_Args&&... __args)
277 {
return c.emplace_back(std::forward<_Args>(__args)...); }
279 template<
typename... _Args>
281 emplace(_Args&&... __args)
282 {
c.emplace_back(std::forward<_Args>(__args)...); }
300 __glibcxx_requires_nonempty();
304#if __cplusplus >= 201103L
307#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
308 noexcept(__is_nothrow_swappable<_Sequence>::value)
310 noexcept(__is_nothrow_swappable<_Tp>::value)
319#if __cpp_deduction_guides >= 201606
320 template<
typename _Container,
321 typename = _RequireNotAllocator<_Container>>
322 queue(_Container) -> queue<typename _Container::value_type, _Container>;
324 template<
typename _Container,
typename _Allocator,
325 typename = _RequireNotAllocator<_Container>,
326 typename = _RequireAllocator<_Allocator>>
327 queue(_Container, _Allocator)
328 -> queue<typename _Container::value_type, _Container>;
342 template<
typename _Tp,
typename _Seq>
345 {
return __x.
c == __y.
c; }
360 template<
typename _Tp,
typename _Seq>
363 {
return __x.
c < __y.
c; }
366 template<
typename _Tp,
typename _Seq>
369 {
return !(__x == __y); }
372 template<
typename _Tp,
typename _Seq>
375 {
return __y < __x; }
378 template<
typename _Tp,
typename _Seq>
381 {
return !(__y < __x); }
384 template<
typename _Tp,
typename _Seq>
387 {
return !(__x < __y); }
389#if __cpp_lib_three_way_comparison
390 template<
typename _Tp, three_way_comparable _Seq>
391 inline compare_three_way_result_t<_Seq>
392 operator<=>(
const queue<_Tp, _Seq>& __x,
const queue<_Tp, _Seq>& __y)
393 {
return __x.c <=> __y.c; }
396#if __cplusplus >= 201103L
397 template<
typename _Tp,
typename _Seq>
399#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
401 typename enable_if<__is_swappable<_Seq>::value>::type
405 swap(queue<_Tp, _Seq>& __x, queue<_Tp, _Seq>& __y)
406 noexcept(
noexcept(__x.swap(__y)))
409 template<
typename _Tp,
typename _Seq,
typename _Alloc>
410 struct uses_allocator<queue<_Tp, _Seq>, _Alloc>
411 :
public uses_allocator<_Seq, _Alloc>::type { };
454 template<
typename _Tp,
typename _Sequence = vector<_Tp>,
455 typename _Compare = less<
typename _Sequence::value_type> >
458#ifdef _GLIBCXX_CONCEPT_CHECKS
460 typedef typename _Sequence::value_type _Sequence_value_type;
461# if __cplusplus < 201103L
462 __glibcxx_class_requires(_Tp, _SGIAssignableConcept)
464 __glibcxx_class_requires(_Sequence, _SequenceConcept)
465 __glibcxx_class_requires(_Sequence, _RandomAccessContainerConcept)
466 __glibcxx_class_requires2(_Tp, _Sequence_value_type, _SameTypeConcept)
467 __glibcxx_class_requires4(_Compare,
bool, _Tp, _Tp,
468 _BinaryFunctionConcept)
471#if __cplusplus >= 201103L
472 template<
typename _Alloc>
473 using _Uses =
typename
476#if __cplusplus >= 201703L
481 "value_type must be the same as the underlying container");
486 typedef typename _Sequence::value_type value_type;
487 typedef typename _Sequence::reference reference;
488 typedef typename _Sequence::const_reference const_reference;
489 typedef typename _Sequence::size_type size_type;
490 typedef _Sequence container_type;
493 typedef _Compare value_compare;
504#if __cplusplus < 201103L
507 const _Sequence& __s = _Sequence())
509 { std::make_heap(c.begin(), c.end(), comp); }
511 template<
typename _Seq = _Sequence,
typename _Requires =
typename
520 { std::make_heap(c.begin(), c.end(), comp); }
523 priority_queue(
const _Compare& __x, _Sequence&& __s = _Sequence())
525 { std::make_heap(c.begin(), c.end(), comp); }
527 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
532 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
534 : c(__a), comp(__x) { }
538 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
541 : c(__c, __a), comp(__x)
542 { std::make_heap(c.begin(), c.end(), comp); }
544 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
545 priority_queue(
const _Compare& __x, _Sequence&& __c,
const _Alloc& __a)
546 : c(
std::
move(__c), __a), comp(__x)
547 { std::make_heap(c.begin(), c.end(), comp); }
549 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
551 : c(__q.c, __a), comp(__q.comp) { }
553 template<
typename _Alloc,
typename _Requires = _Uses<_Alloc>>
573#if __cplusplus < 201103L
574 template<
typename _InputIterator>
576 const _Compare& __x = _Compare(),
577 const _Sequence& __s = _Sequence())
580 __glibcxx_requires_valid_range(__first, __last);
581 c.insert(c.end(), __first, __last);
582 std::make_heap(c.begin(), c.end(), comp);
585 template<
typename _InputIterator>
588 const _Sequence& __s)
591 __glibcxx_requires_valid_range(__first, __last);
592 c.insert(c.end(), __first, __last);
593 std::make_heap(c.begin(), c.end(), comp);
596 template<
typename _InputIterator>
598 const _Compare& __x = _Compare(),
599 _Sequence&& __s = _Sequence())
602 __glibcxx_requires_valid_range(__first, __last);
603 c.insert(c.end(), __first, __last);
604 std::make_heap(c.begin(), c.end(), comp);
611 _GLIBCXX_NODISCARD
bool
613 {
return c.empty(); }
627 __glibcxx_requires_nonempty();
643 std::push_heap(c.begin(), c.end(), comp);
646#if __cplusplus >= 201103L
648 push(value_type&& __x)
651 std::push_heap(c.begin(), c.end(), comp);
654 template<
typename... _Args>
656 emplace(_Args&&... __args)
658 c.emplace_back(std::forward<_Args>(__args)...);
659 std::push_heap(c.begin(), c.end(), comp);
677 __glibcxx_requires_nonempty();
678 std::pop_heap(c.begin(), c.end(), comp);
682#if __cplusplus >= 201103L
686#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
687 __is_nothrow_swappable<_Sequence>,
689 __is_nothrow_swappable<_Tp>,
691 __is_nothrow_swappable<_Compare>
696 swap(comp, __pq.comp);
701#if __cpp_deduction_guides >= 201606
702 template<
typename _Compare,
typename _Container,
703 typename = _RequireNotAllocator<_Compare>,
704 typename = _RequireNotAllocator<_Container>>
705 priority_queue(_Compare, _Container)
706 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
708 template<
typename _InputIterator,
typename _ValT
709 =
typename iterator_traits<_InputIterator>::value_type,
710 typename _Compare = less<_ValT>,
711 typename _Container = vector<_ValT>,
712 typename = _RequireInputIter<_InputIterator>,
713 typename = _RequireNotAllocator<_Compare>,
714 typename = _RequireNotAllocator<_Container>>
715 priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(),
716 _Container = _Container())
717 -> priority_queue<_ValT, _Container, _Compare>;
719 template<
typename _Compare,
typename _Container,
typename _Allocator,
720 typename = _RequireNotAllocator<_Compare>,
721 typename = _RequireNotAllocator<_Container>,
722 typename = _RequireAllocator<_Allocator>>
723 priority_queue(_Compare, _Container, _Allocator)
724 -> priority_queue<typename _Container::value_type, _Container, _Compare>;
729#if __cplusplus >= 201103L
730 template<
typename _Tp,
typename _Sequence,
typename _Compare>
732#if __cplusplus > 201402L || !defined(__STRICT_ANSI__)
734 typename enable_if<__and_<__is_swappable<_Sequence>,
735 __is_swappable<_Compare>>::value>::type
739 swap(priority_queue<_Tp, _Sequence, _Compare>& __x,
740 priority_queue<_Tp, _Sequence, _Compare>& __y)
741 noexcept(
noexcept(__x.swap(__y)))
744 template<
typename _Tp,
typename _Sequence,
typename _Compare,
746 struct uses_allocator<priority_queue<_Tp, _Sequence, _Compare>, _Alloc>
747 :
public uses_allocator<_Sequence, _Alloc>::type { };
750_GLIBCXX_END_NAMESPACE_VERSION
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
void swap(any &__x, any &__y) noexcept
Exchange the states of two any objects.
ISO C++ entities toplevel namespace is std.
Define a member typedef type only if a boolean constant is true.
A standard container giving FIFO behavior.
void push(const value_type &__x)
Add data to the end of the queue.
_Sequence c
c is the underlying container.
const_reference back() const
void pop()
Removes first element.
queue()
Default constructor creates no elements.
const_reference front() const
A standard container automatically sorting its contents.
priority_queue(_InputIterator __first, _InputIterator __last, const _Compare &__x, const _Sequence &__s)
Builds a queue from a range.
void pop()
Removes first element.
const_reference top() const
void push(const value_type &__x)
Add data to the queue.
priority_queue()
Default constructor creates no elements.