codekingpro/portable-devtools
114k
1// -*- C++ -*-2//===--------------------------- queue ------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCUDACXX_QUEUE11#define _LIBCUDACXX_QUEUE12 13/*14 queue synopsis15 16namespace std17{18 19template <class T, class Container = deque<T>>20class queue21{22public:23 typedef Container container_type;24 typedef typename container_type::value_type value_type;25 typedef typename container_type::reference reference;26 typedef typename container_type::const_reference const_reference;27 typedef typename container_type::size_type size_type;28 29protected:30 container_type c;31 32public:33 queue() = default;34 ~queue() = default;35 36 queue(const queue& q) = default;37 queue(queue&& q) = default;38 39 queue& operator=(const queue& q) = default;40 queue& operator=(queue&& q) = default;41 42 explicit queue(const container_type& c);43 explicit queue(container_type&& c)44 template <class Alloc>45 explicit queue(const Alloc& a);46 template <class Alloc>47 queue(const container_type& c, const Alloc& a);48 template <class Alloc>49 queue(container_type&& c, const Alloc& a);50 template <class Alloc>51 queue(const queue& q, const Alloc& a);52 template <class Alloc>53 queue(queue&& q, const Alloc& a);54 55 bool empty() const;56 size_type size() const;57 58 reference front();59 const_reference front() const;60 reference back();61 const_reference back() const;62 63 void push(const value_type& v);64 void push(value_type&& v);65 template <class... Args> reference emplace(Args&&... args); // reference in C++1766 void pop();67 68 void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>)69};70 71template<class Container>72 queue(Container) -> queue<typename Container::value_type, Container>; // C++1773 74template<class Container, class Allocator>75 queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++1776 77template <class T, class Container>78 bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);79 80template <class T, class Container>81 bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);82 83template <class T, class Container>84 bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);85 86template <class T, class Container>87 bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);88 89template <class T, class Container>90 bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);91 92template <class T, class Container>93 bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);94 95template <class T, class Container>96 void swap(queue<T, Container>& x, queue<T, Container>& y)97 noexcept(noexcept(x.swap(y)));98 99template <class T, class Container = vector<T>,100 class Compare = less<typename Container::value_type>>101class priority_queue102{103public:104 typedef Container container_type;105 typedef typename container_type::value_type value_type;106 typedef typename container_type::reference reference;107 typedef typename container_type::const_reference const_reference;108 typedef typename container_type::size_type size_type;109 110protected:111 container_type c;112 Compare comp;113 114public:115 priority_queue() = default;116 ~priority_queue() = default;117 118 priority_queue(const priority_queue& q) = default;119 priority_queue(priority_queue&& q) = default;120 121 priority_queue& operator=(const priority_queue& q) = default;122 priority_queue& operator=(priority_queue&& q) = default;123 124 explicit priority_queue(const Compare& comp);125 priority_queue(const Compare& comp, const container_type& c);126 explicit priority_queue(const Compare& comp, container_type&& c);127 template <class InputIterator>128 priority_queue(InputIterator first, InputIterator last,129 const Compare& comp = Compare());130 template <class InputIterator>131 priority_queue(InputIterator first, InputIterator last,132 const Compare& comp, const container_type& c);133 template <class InputIterator>134 priority_queue(InputIterator first, InputIterator last,135 const Compare& comp, container_type&& c);136 template <class Alloc>137 explicit priority_queue(const Alloc& a);138 template <class Alloc>139 priority_queue(const Compare& comp, const Alloc& a);140 template <class Alloc>141 priority_queue(const Compare& comp, const container_type& c,142 const Alloc& a);143 template <class Alloc>144 priority_queue(const Compare& comp, container_type&& c,145 const Alloc& a);146 template <class Alloc>147 priority_queue(const priority_queue& q, const Alloc& a);148 template <class Alloc>149 priority_queue(priority_queue&& q, const Alloc& a);150 151 bool empty() const;152 size_type size() const;153 const_reference top() const;154 155 void push(const value_type& v);156 void push(value_type&& v);157 template <class... Args> void emplace(Args&&... args);158 void pop();159 160 void swap(priority_queue& q)161 noexcept(is_nothrow_swappable_v<Container> &&162 is_nothrow_swappable_v<Comp>)163};164 165template <class Compare, class Container>166priority_queue(Compare, Container)167 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17168 169template<class InputIterator,170 class Compare = less<typename iterator_traits<InputIterator>::value_type>,171 class Container = vector<typename iterator_traits<InputIterator>::value_type>>172priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())173 -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>; // C++17174 175template<class Compare, class Container, class Allocator>176priority_queue(Compare, Container, Allocator)177 -> priority_queue<typename Container::value_type, Container, Compare>; // C++17178 179template <class T, class Container, class Compare>180 void swap(priority_queue<T, Container, Compare>& x,181 priority_queue<T, Container, Compare>& y)182 noexcept(noexcept(x.swap(y)));183 184} // std185 186*/187 188#include <__config>189#include <deque>190#include <vector>191#include <functional>192#include <algorithm>193 194#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)195# pragma GCC system_header196#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)197# pragma clang system_header198#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)199# pragma system_header200#endif // no system header201 202_LIBCUDACXX_BEGIN_NAMESPACE_STD203 204template <class _Tp, class _Container = deque<_Tp> > class _LIBCUDACXX_TEMPLATE_VIS queue;205 206template <class _Tp, class _Container>207_LIBCUDACXX_INLINE_VISIBILITY208bool209operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);210 211template <class _Tp, class _Container>212_LIBCUDACXX_INLINE_VISIBILITY213bool214operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y);215 216template <class _Tp, class _Container /*= deque<_Tp>*/>217class _LIBCUDACXX_TEMPLATE_VIS queue218{219public:220 typedef _Container container_type;221 typedef typename container_type::value_type value_type;222 typedef typename container_type::reference reference;223 typedef typename container_type::const_reference const_reference;224 typedef typename container_type::size_type size_type;225 static_assert((is_same<_Tp, value_type>::value), "" );226 227protected:228 container_type c;229 230public:231 _LIBCUDACXX_INLINE_VISIBILITY232 queue()233 noexcept(is_nothrow_default_constructible<container_type>::value)234 : c() {}235 236 _LIBCUDACXX_INLINE_VISIBILITY237 queue(const queue& __q) : c(__q.c) {}238 239 _LIBCUDACXX_INLINE_VISIBILITY240 queue& operator=(const queue& __q) {c = __q.c; return *this;}241 242 _LIBCUDACXX_INLINE_VISIBILITY243 queue(queue&& __q)244 noexcept(is_nothrow_move_constructible<container_type>::value)245 : c(_CUDA_VSTD::move(__q.c)) {}246 247 _LIBCUDACXX_INLINE_VISIBILITY248 queue& operator=(queue&& __q)249 noexcept(is_nothrow_move_assignable<container_type>::value)250 {c = _CUDA_VSTD::move(__q.c); return *this;}251 252 _LIBCUDACXX_INLINE_VISIBILITY253 explicit queue(const container_type& __c) : c(__c) {}254 _LIBCUDACXX_INLINE_VISIBILITY255 explicit queue(container_type&& __c) : c(_CUDA_VSTD::move(__c)) {}256 257 template <class _Alloc>258 _LIBCUDACXX_INLINE_VISIBILITY259 explicit queue(const _Alloc& __a,260 typename enable_if<uses_allocator<container_type,261 _Alloc>::value>::type* = 0)262 : c(__a) {}263 template <class _Alloc>264 _LIBCUDACXX_INLINE_VISIBILITY265 queue(const queue& __q, const _Alloc& __a,266 typename enable_if<uses_allocator<container_type,267 _Alloc>::value>::type* = 0)268 : c(__q.c, __a) {}269 template <class _Alloc>270 _LIBCUDACXX_INLINE_VISIBILITY271 queue(const container_type& __c, const _Alloc& __a,272 typename enable_if<uses_allocator<container_type,273 _Alloc>::value>::type* = 0)274 : c(__c, __a) {}275 276 template <class _Alloc>277 _LIBCUDACXX_INLINE_VISIBILITY278 queue(container_type&& __c, const _Alloc& __a,279 typename enable_if<uses_allocator<container_type,280 _Alloc>::value>::type* = 0)281 : c(_CUDA_VSTD::move(__c), __a) {}282 template <class _Alloc>283 _LIBCUDACXX_INLINE_VISIBILITY284 queue(queue&& __q, const _Alloc& __a,285 typename enable_if<uses_allocator<container_type,286 _Alloc>::value>::type* = 0)287 : c(_CUDA_VSTD::move(__q.c), __a) {}288 289 _LIBCUDACXX_NODISCARD_AFTER_CXX17 _LIBCUDACXX_INLINE_VISIBILITY290 bool empty() const {return c.empty();}291 _LIBCUDACXX_INLINE_VISIBILITY292 size_type size() const {return c.size();}293 294 _LIBCUDACXX_INLINE_VISIBILITY295 reference front() {return c.front();}296 _LIBCUDACXX_INLINE_VISIBILITY297 const_reference front() const {return c.front();}298 _LIBCUDACXX_INLINE_VISIBILITY299 reference back() {return c.back();}300 _LIBCUDACXX_INLINE_VISIBILITY301 const_reference back() const {return c.back();}302 303 _LIBCUDACXX_INLINE_VISIBILITY304 void push(const value_type& __v) {c.push_back(__v);}305 _LIBCUDACXX_INLINE_VISIBILITY306 void push(value_type&& __v) {c.push_back(_CUDA_VSTD::move(__v));}307 template <class... _Args>308 _LIBCUDACXX_INLINE_VISIBILITY309#if _LIBCUDACXX_STD_VER > 14310 decltype(auto) emplace(_Args&&... __args)311 { return c.emplace_back(_CUDA_VSTD::forward<_Args>(__args)...);}312#else313 void emplace(_Args&&... __args)314 { c.emplace_back(_CUDA_VSTD::forward<_Args>(__args)...);}315#endif316 _LIBCUDACXX_INLINE_VISIBILITY317 void pop() {c.pop_front();}318 319 _LIBCUDACXX_INLINE_VISIBILITY320 void swap(queue& __q)321 noexcept(__is_nothrow_swappable<container_type>::value)322 {323 using _CUDA_VSTD::swap;324 swap(c, __q.c);325 }326 327 template <class _T1, class _C1>328 friend329 _LIBCUDACXX_INLINE_VISIBILITY330 bool331 operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);332 333 template <class _T1, class _C1>334 friend335 _LIBCUDACXX_INLINE_VISIBILITY336 bool337 operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y);338};339 340#ifndef _LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES341template<class _Container,342 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type343>344queue(_Container)345 -> queue<typename _Container::value_type, _Container>;346 347template<class _Container,348 class _Alloc,349 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,350 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type351>352queue(_Container, _Alloc)353 -> queue<typename _Container::value_type, _Container>;354#endif355 356template <class _Tp, class _Container>357inline _LIBCUDACXX_INLINE_VISIBILITY358bool359operator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)360{361 return __x.c == __y.c;362}363 364template <class _Tp, class _Container>365inline _LIBCUDACXX_INLINE_VISIBILITY366bool367operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)368{369 return __x.c < __y.c;370}371 372template <class _Tp, class _Container>373inline _LIBCUDACXX_INLINE_VISIBILITY374bool375operator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)376{377 return !(__x == __y);378}379 380template <class _Tp, class _Container>381inline _LIBCUDACXX_INLINE_VISIBILITY382bool383operator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)384{385 return __y < __x;386}387 388template <class _Tp, class _Container>389inline _LIBCUDACXX_INLINE_VISIBILITY390bool391operator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)392{393 return !(__x < __y);394}395 396template <class _Tp, class _Container>397inline _LIBCUDACXX_INLINE_VISIBILITY398bool399operator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y)400{401 return !(__y < __x);402}403 404template <class _Tp, class _Container>405inline _LIBCUDACXX_INLINE_VISIBILITY406typename enable_if<407 __is_swappable<_Container>::value,408 void409>::type410swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y)411 noexcept(noexcept(__x.swap(__y)))412{413 __x.swap(__y);414}415 416template <class _Tp, class _Container, class _Alloc>417struct _LIBCUDACXX_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc>418 : public uses_allocator<_Container, _Alloc>419{420};421 422template <class _Tp, class _Container = vector<_Tp>,423 class _Compare = less<typename _Container::value_type> >424class _LIBCUDACXX_TEMPLATE_VIS priority_queue425{426public:427 typedef _Container container_type;428 typedef _Compare value_compare;429 typedef typename container_type::value_type value_type;430 typedef typename container_type::reference reference;431 typedef typename container_type::const_reference const_reference;432 typedef typename container_type::size_type size_type;433 static_assert((is_same<_Tp, value_type>::value), "" );434 435protected:436 container_type c;437 value_compare comp;438 439public:440 _LIBCUDACXX_INLINE_VISIBILITY441 priority_queue()442 noexcept(is_nothrow_default_constructible<container_type>::value &&443 is_nothrow_default_constructible<value_compare>::value)444 : c(), comp() {}445 446 _LIBCUDACXX_INLINE_VISIBILITY447 priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {}448 449 _LIBCUDACXX_INLINE_VISIBILITY450 priority_queue& operator=(const priority_queue& __q)451 {c = __q.c; comp = __q.comp; return *this;}452 453 _LIBCUDACXX_INLINE_VISIBILITY454 priority_queue(priority_queue&& __q)455 noexcept(is_nothrow_move_constructible<container_type>::value &&456 is_nothrow_move_constructible<value_compare>::value)457 : c(_CUDA_VSTD::move(__q.c)), comp(_CUDA_VSTD::move(__q.comp)) {}458 459 _LIBCUDACXX_INLINE_VISIBILITY460 priority_queue& operator=(priority_queue&& __q)461 noexcept(is_nothrow_move_assignable<container_type>::value &&462 is_nothrow_move_assignable<value_compare>::value)463 {c = _CUDA_VSTD::move(__q.c); comp = _CUDA_VSTD::move(__q.comp); return *this;}464 465 _LIBCUDACXX_INLINE_VISIBILITY466 explicit priority_queue(const value_compare& __comp)467 : c(), comp(__comp) {}468 _LIBCUDACXX_INLINE_VISIBILITY469 priority_queue(const value_compare& __comp, const container_type& __c);470 _LIBCUDACXX_INLINE_VISIBILITY471 explicit priority_queue(const value_compare& __comp, container_type&& __c);472 473 template <class _InputIter>474 _LIBCUDACXX_INLINE_VISIBILITY475 priority_queue(_InputIter __f, _InputIter __l,476 const value_compare& __comp = value_compare());477 template <class _InputIter>478 _LIBCUDACXX_INLINE_VISIBILITY479 priority_queue(_InputIter __f, _InputIter __l,480 const value_compare& __comp, const container_type& __c);481 template <class _InputIter>482 _LIBCUDACXX_INLINE_VISIBILITY483 priority_queue(_InputIter __f, _InputIter __l,484 const value_compare& __comp, container_type&& __c);485 template <class _Alloc>486 _LIBCUDACXX_INLINE_VISIBILITY487 explicit priority_queue(const _Alloc& __a,488 typename enable_if<uses_allocator<container_type,489 _Alloc>::value>::type* = 0);490 template <class _Alloc>491 _LIBCUDACXX_INLINE_VISIBILITY492 priority_queue(const value_compare& __comp, const _Alloc& __a,493 typename enable_if<uses_allocator<container_type,494 _Alloc>::value>::type* = 0);495 template <class _Alloc>496 _LIBCUDACXX_INLINE_VISIBILITY497 priority_queue(const value_compare& __comp, const container_type& __c,498 const _Alloc& __a,499 typename enable_if<uses_allocator<container_type,500 _Alloc>::value>::type* = 0);501 template <class _Alloc>502 _LIBCUDACXX_INLINE_VISIBILITY503 priority_queue(const priority_queue& __q, const _Alloc& __a,504 typename enable_if<uses_allocator<container_type,505 _Alloc>::value>::type* = 0);506 template <class _Alloc>507 _LIBCUDACXX_INLINE_VISIBILITY508 priority_queue(const value_compare& __comp, container_type&& __c,509 const _Alloc& __a,510 typename enable_if<uses_allocator<container_type,511 _Alloc>::value>::type* = 0);512 template <class _Alloc>513 _LIBCUDACXX_INLINE_VISIBILITY514 priority_queue(priority_queue&& __q, const _Alloc& __a,515 typename enable_if<uses_allocator<container_type,516 _Alloc>::value>::type* = 0);517 518 _LIBCUDACXX_NODISCARD_AFTER_CXX17 _LIBCUDACXX_INLINE_VISIBILITY519 bool empty() const {return c.empty();}520 _LIBCUDACXX_INLINE_VISIBILITY521 size_type size() const {return c.size();}522 _LIBCUDACXX_INLINE_VISIBILITY523 const_reference top() const {return c.front();}524 525 _LIBCUDACXX_INLINE_VISIBILITY526 void push(const value_type& __v);527 _LIBCUDACXX_INLINE_VISIBILITY528 void push(value_type&& __v);529 template <class... _Args>530 _LIBCUDACXX_INLINE_VISIBILITY531 void emplace(_Args&&... __args);532 _LIBCUDACXX_INLINE_VISIBILITY533 void pop();534 535 _LIBCUDACXX_INLINE_VISIBILITY536 void swap(priority_queue& __q)537 noexcept(__is_nothrow_swappable<container_type>::value &&538 __is_nothrow_swappable<value_compare>::value);539};540 541#ifndef _LIBCUDACXX_HAS_NO_DEDUCTION_GUIDES542template <class _Compare,543 class _Container,544 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,545 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type546>547priority_queue(_Compare, _Container)548 -> priority_queue<typename _Container::value_type, _Container, _Compare>;549 550template<class _InputIterator,551 class _Compare = less<typename iterator_traits<_InputIterator>::value_type>,552 class _Container = vector<typename iterator_traits<_InputIterator>::value_type>,553 class = typename enable_if< __is_cpp17_input_iterator<_InputIterator>::value, nullptr_t>::type,554 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,555 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type556>557priority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container())558 -> priority_queue<typename iterator_traits<_InputIterator>::value_type, _Container, _Compare>;559 560template<class _Compare,561 class _Container,562 class _Alloc,563 class = typename enable_if<!__is_allocator<_Compare>::value, nullptr_t>::type,564 class = typename enable_if<!__is_allocator<_Container>::value, nullptr_t>::type,565 class = typename enable_if< __is_allocator<_Alloc>::value, nullptr_t>::type566>567priority_queue(_Compare, _Container, _Alloc)568 -> priority_queue<typename _Container::value_type, _Container, _Compare>;569#endif570 571template <class _Tp, class _Container, class _Compare>572inline573priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp,574 const container_type& __c)575 : c(__c),576 comp(__comp)577{578 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);579}580 581template <class _Tp, class _Container, class _Compare>582inline583priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,584 container_type&& __c)585 : c(_CUDA_VSTD::move(__c)),586 comp(__comp)587{588 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);589}590 591template <class _Tp, class _Container, class _Compare>592template <class _InputIter>593inline594priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,595 const value_compare& __comp)596 : c(__f, __l),597 comp(__comp)598{599 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);600}601 602template <class _Tp, class _Container, class _Compare>603template <class _InputIter>604inline605priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,606 const value_compare& __comp,607 const container_type& __c)608 : c(__c),609 comp(__comp)610{611 c.insert(c.end(), __f, __l);612 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);613}614 615template <class _Tp, class _Container, class _Compare>616template <class _InputIter>617inline618priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l,619 const value_compare& __comp,620 container_type&& __c)621 : c(_CUDA_VSTD::move(__c)),622 comp(__comp)623{624 c.insert(c.end(), __f, __l);625 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);626}627 628template <class _Tp, class _Container, class _Compare>629template <class _Alloc>630inline631priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a,632 typename enable_if<uses_allocator<container_type,633 _Alloc>::value>::type*)634 : c(__a)635{636}637 638template <class _Tp, class _Container, class _Compare>639template <class _Alloc>640inline641priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,642 const _Alloc& __a,643 typename enable_if<uses_allocator<container_type,644 _Alloc>::value>::type*)645 : c(__a),646 comp(__comp)647{648}649 650template <class _Tp, class _Container, class _Compare>651template <class _Alloc>652inline653priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,654 const container_type& __c,655 const _Alloc& __a,656 typename enable_if<uses_allocator<container_type,657 _Alloc>::value>::type*)658 : c(__c, __a),659 comp(__comp)660{661 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);662}663 664template <class _Tp, class _Container, class _Compare>665template <class _Alloc>666inline667priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q,668 const _Alloc& __a,669 typename enable_if<uses_allocator<container_type,670 _Alloc>::value>::type*)671 : c(__q.c, __a),672 comp(__q.comp)673{674 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);675}676 677template <class _Tp, class _Container, class _Compare>678template <class _Alloc>679inline680priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp,681 container_type&& __c,682 const _Alloc& __a,683 typename enable_if<uses_allocator<container_type,684 _Alloc>::value>::type*)685 : c(_CUDA_VSTD::move(__c), __a),686 comp(__comp)687{688 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);689}690 691template <class _Tp, class _Container, class _Compare>692template <class _Alloc>693inline694priority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q,695 const _Alloc& __a,696 typename enable_if<uses_allocator<container_type,697 _Alloc>::value>::type*)698 : c(_CUDA_VSTD::move(__q.c), __a),699 comp(_CUDA_VSTD::move(__q.comp))700{701 _CUDA_VSTD::make_heap(c.begin(), c.end(), comp);702}703 704template <class _Tp, class _Container, class _Compare>705inline706void707priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v)708{709 c.push_back(__v);710 _CUDA_VSTD::push_heap(c.begin(), c.end(), comp);711}712 713template <class _Tp, class _Container, class _Compare>714inline715void716priority_queue<_Tp, _Container, _Compare>::push(value_type&& __v)717{718 c.push_back(_CUDA_VSTD::move(__v));719 _CUDA_VSTD::push_heap(c.begin(), c.end(), comp);720}721 722template <class _Tp, class _Container, class _Compare>723template <class... _Args>724inline725void726priority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args)727{728 c.emplace_back(_CUDA_VSTD::forward<_Args>(__args)...);729 _CUDA_VSTD::push_heap(c.begin(), c.end(), comp);730}731 732template <class _Tp, class _Container, class _Compare>733inline734void735priority_queue<_Tp, _Container, _Compare>::pop()736{737 _CUDA_VSTD::pop_heap(c.begin(), c.end(), comp);738 c.pop_back();739}740 741template <class _Tp, class _Container, class _Compare>742inline743void744priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q)745 noexcept(__is_nothrow_swappable<container_type>::value &&746 __is_nothrow_swappable<value_compare>::value)747{748 using _CUDA_VSTD::swap;749 swap(c, __q.c);750 swap(comp, __q.comp);751}752 753template <class _Tp, class _Container, class _Compare>754inline _LIBCUDACXX_INLINE_VISIBILITY755typename enable_if<756 __is_swappable<_Container>::value757 && __is_swappable<_Compare>::value,758 void759>::type760swap(priority_queue<_Tp, _Container, _Compare>& __x,761 priority_queue<_Tp, _Container, _Compare>& __y)762 noexcept(noexcept(__x.swap(__y)))763{764 __x.swap(__y);765}766 767template <class _Tp, class _Container, class _Compare, class _Alloc>768struct _LIBCUDACXX_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc>769 : public uses_allocator<_Container, _Alloc>770{771};772 773_LIBCUDACXX_END_NAMESPACE_STD774 775#endif // _LIBCUDACXX_QUEUE776 