13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===--------------------------- queue ------------------------------------===// 33e519524SHoward Hinnant// 457b08b09SChandler Carruth// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 557b08b09SChandler Carruth// See https://llvm.org/LICENSE.txt for license information. 657b08b09SChandler Carruth// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 73e519524SHoward Hinnant// 83e519524SHoward Hinnant//===----------------------------------------------------------------------===// 93e519524SHoward Hinnant 103e519524SHoward Hinnant#ifndef _LIBCPP_QUEUE 113e519524SHoward Hinnant#define _LIBCPP_QUEUE 123e519524SHoward Hinnant 133e519524SHoward Hinnant/* 143e519524SHoward Hinnant queue synopsis 153e519524SHoward Hinnant 163e519524SHoward Hinnantnamespace std 173e519524SHoward Hinnant{ 183e519524SHoward Hinnant 193e519524SHoward Hinnanttemplate <class T, class Container = deque<T>> 203e519524SHoward Hinnantclass queue 213e519524SHoward Hinnant{ 223e519524SHoward Hinnantpublic: 233e519524SHoward Hinnant typedef Container container_type; 243e519524SHoward Hinnant typedef typename container_type::value_type value_type; 253e519524SHoward Hinnant typedef typename container_type::reference reference; 263e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 273e519524SHoward Hinnant typedef typename container_type::size_type size_type; 283e519524SHoward Hinnant 293e519524SHoward Hinnantprotected: 303e519524SHoward Hinnant container_type c; 313e519524SHoward Hinnant 323e519524SHoward Hinnantpublic: 336971d826SHoward Hinnant queue() = default; 346971d826SHoward Hinnant ~queue() = default; 356971d826SHoward Hinnant 366971d826SHoward Hinnant queue(const queue& q) = default; 376971d826SHoward Hinnant queue(queue&& q) = default; 386971d826SHoward Hinnant 396971d826SHoward Hinnant queue& operator=(const queue& q) = default; 406971d826SHoward Hinnant queue& operator=(queue&& q) = default; 416971d826SHoward Hinnant 423e519524SHoward Hinnant explicit queue(const container_type& c); 436971d826SHoward Hinnant explicit queue(container_type&& c) 443e519524SHoward Hinnant template <class Alloc> 453e519524SHoward Hinnant explicit queue(const Alloc& a); 463e519524SHoward Hinnant template <class Alloc> 473e519524SHoward Hinnant queue(const container_type& c, const Alloc& a); 483e519524SHoward Hinnant template <class Alloc> 493e519524SHoward Hinnant queue(container_type&& c, const Alloc& a); 503e519524SHoward Hinnant template <class Alloc> 516971d826SHoward Hinnant queue(const queue& q, const Alloc& a); 526971d826SHoward Hinnant template <class Alloc> 533e519524SHoward Hinnant queue(queue&& q, const Alloc& a); 543e519524SHoward Hinnant 553e519524SHoward Hinnant bool empty() const; 563e519524SHoward Hinnant size_type size() const; 573e519524SHoward Hinnant 583e519524SHoward Hinnant reference front(); 593e519524SHoward Hinnant const_reference front() const; 603e519524SHoward Hinnant reference back(); 613e519524SHoward Hinnant const_reference back() const; 623e519524SHoward Hinnant 633e519524SHoward Hinnant void push(const value_type& v); 643e519524SHoward Hinnant void push(value_type&& v); 6563b560beSMarshall Clow template <class... Args> reference emplace(Args&&... args); // reference in C++17 663e519524SHoward Hinnant void pop(); 673e519524SHoward Hinnant 68f07dd8d0SEric Fiselier void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) 693e519524SHoward Hinnant}; 703e519524SHoward Hinnant 715b8b8b5dSMarshall Clowtemplate<class Container> 725b8b8b5dSMarshall Clow queue(Container) -> queue<typename Container::value_type, Container>; // C++17 735b8b8b5dSMarshall Clow 745b8b8b5dSMarshall Clowtemplate<class Container, class Allocator> 755b8b8b5dSMarshall Clow queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 765b8b8b5dSMarshall Clow 773e519524SHoward Hinnanttemplate <class T, class Container> 783e519524SHoward Hinnant bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); 793e519524SHoward Hinnant 803e519524SHoward Hinnanttemplate <class T, class Container> 813e519524SHoward Hinnant bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); 823e519524SHoward Hinnant 833e519524SHoward Hinnanttemplate <class T, class Container> 843e519524SHoward Hinnant bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); 853e519524SHoward Hinnant 863e519524SHoward Hinnanttemplate <class T, class Container> 873e519524SHoward Hinnant bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); 883e519524SHoward Hinnant 893e519524SHoward Hinnanttemplate <class T, class Container> 903e519524SHoward Hinnant bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); 913e519524SHoward Hinnant 923e519524SHoward Hinnanttemplate <class T, class Container> 933e519524SHoward Hinnant bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); 943e519524SHoward Hinnant 953e519524SHoward Hinnanttemplate <class T, class Container> 966971d826SHoward Hinnant void swap(queue<T, Container>& x, queue<T, Container>& y) 976971d826SHoward Hinnant noexcept(noexcept(x.swap(y))); 983e519524SHoward Hinnant 993e519524SHoward Hinnanttemplate <class T, class Container = vector<T>, 1003e519524SHoward Hinnant class Compare = less<typename Container::value_type>> 1013e519524SHoward Hinnantclass priority_queue 1023e519524SHoward Hinnant{ 1033e519524SHoward Hinnantpublic: 1043e519524SHoward Hinnant typedef Container container_type; 1053e519524SHoward Hinnant typedef typename container_type::value_type value_type; 1063e519524SHoward Hinnant typedef typename container_type::reference reference; 1073e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 1083e519524SHoward Hinnant typedef typename container_type::size_type size_type; 1093e519524SHoward Hinnant 1103e519524SHoward Hinnantprotected: 1113e519524SHoward Hinnant container_type c; 1123e519524SHoward Hinnant Compare comp; 1133e519524SHoward Hinnant 1143e519524SHoward Hinnantpublic: 115a11f8b1aSMarek Kurdej priority_queue() : priority_queue(Compare()) {} // C++20 116a11f8b1aSMarek Kurdej explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} 117a11f8b1aSMarek Kurdej priority_queue(const Compare& x, const Container&); 118a11f8b1aSMarek Kurdej explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 119a11f8b1aSMarek Kurdej priority_queue(const Compare& x, Container&&); // C++20 1203e519524SHoward Hinnant template <class InputIterator> 1213e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1223e519524SHoward Hinnant const Compare& comp = Compare()); 1233e519524SHoward Hinnant template <class InputIterator> 1243e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1253894a8a4SArthur O'Dwyer const Compare& comp, const Container& c); 1263e519524SHoward Hinnant template <class InputIterator> 1273e519524SHoward Hinnant priority_queue(InputIterator first, InputIterator last, 1283894a8a4SArthur O'Dwyer const Compare& comp, Container&& c); 1293e519524SHoward Hinnant template <class Alloc> 1303e519524SHoward Hinnant explicit priority_queue(const Alloc& a); 1313e519524SHoward Hinnant template <class Alloc> 1323e519524SHoward Hinnant priority_queue(const Compare& comp, const Alloc& a); 1333e519524SHoward Hinnant template <class Alloc> 1343894a8a4SArthur O'Dwyer priority_queue(const Compare& comp, const Container& c, 1353e519524SHoward Hinnant const Alloc& a); 1363e519524SHoward Hinnant template <class Alloc> 1373894a8a4SArthur O'Dwyer priority_queue(const Compare& comp, Container&& c, 1383e519524SHoward Hinnant const Alloc& a); 1393894a8a4SArthur O'Dwyer template <class InputIterator> 1403894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1413894a8a4SArthur O'Dwyer const Alloc& a); 1423894a8a4SArthur O'Dwyer template <class InputIterator> 1433894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1443894a8a4SArthur O'Dwyer const Compare& comp, const Alloc& a); 1453894a8a4SArthur O'Dwyer template <class InputIterator> 1463894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1473894a8a4SArthur O'Dwyer const Compare& comp, const Container& c, const Alloc& a); 1483894a8a4SArthur O'Dwyer template <class InputIterator> 1493894a8a4SArthur O'Dwyer priority_queue(InputIterator first, InputIterator last, 1503894a8a4SArthur O'Dwyer const Compare& comp, Container&& c, const Alloc& a); 1513e519524SHoward Hinnant template <class Alloc> 1526971d826SHoward Hinnant priority_queue(const priority_queue& q, const Alloc& a); 1536971d826SHoward Hinnant template <class Alloc> 1543e519524SHoward Hinnant priority_queue(priority_queue&& q, const Alloc& a); 1553e519524SHoward Hinnant 1563e519524SHoward Hinnant bool empty() const; 1573e519524SHoward Hinnant size_type size() const; 1583e519524SHoward Hinnant const_reference top() const; 1593e519524SHoward Hinnant 1603e519524SHoward Hinnant void push(const value_type& v); 1613e519524SHoward Hinnant void push(value_type&& v); 1623e519524SHoward Hinnant template <class... Args> void emplace(Args&&... args); 1633e519524SHoward Hinnant void pop(); 1643e519524SHoward Hinnant 1656971d826SHoward Hinnant void swap(priority_queue& q) 166f07dd8d0SEric Fiselier noexcept(is_nothrow_swappable_v<Container> && 167f07dd8d0SEric Fiselier is_nothrow_swappable_v<Comp>) 1683e519524SHoward Hinnant}; 1693e519524SHoward Hinnant 1705b8b8b5dSMarshall Clowtemplate <class Compare, class Container> 1715b8b8b5dSMarshall Clowpriority_queue(Compare, Container) 1725b8b8b5dSMarshall Clow -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1735b8b8b5dSMarshall Clow 1745b8b8b5dSMarshall Clowtemplate<class InputIterator, 1753894a8a4SArthur O'Dwyer class Compare = less<iter-value-type<InputIterator>>, 1763894a8a4SArthur O'Dwyer class Container = vector<iter-value-type<InputIterator>>> 1775b8b8b5dSMarshall Clowpriority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) 1783894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 1795b8b8b5dSMarshall Clow 1805b8b8b5dSMarshall Clowtemplate<class Compare, class Container, class Allocator> 1815b8b8b5dSMarshall Clowpriority_queue(Compare, Container, Allocator) 1825b8b8b5dSMarshall Clow -> priority_queue<typename Container::value_type, Container, Compare>; // C++17 1835b8b8b5dSMarshall Clow 1843894a8a4SArthur O'Dwyertemplate<class InputIterator, class Allocator> 1853894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Allocator) 1863894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, 1873894a8a4SArthur O'Dwyer vector<iter-value-type<InputIterator>, Allocator>, 1883894a8a4SArthur O'Dwyer less<iter-value-type<InputIterator>>>; 1893894a8a4SArthur O'Dwyer 1903894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Allocator> 1913894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Allocator) 1923894a8a4SArthur O'Dwyer -> priority_queue<iter-value-type<InputIterator>, 1933894a8a4SArthur O'Dwyer vector<iter-value-type<InputIterator>, Allocator>, Compare>; 1943894a8a4SArthur O'Dwyer 1953894a8a4SArthur O'Dwyertemplate<class InputIterator, class Compare, class Container, class Allocator> 1963894a8a4SArthur O'Dwyerpriority_queue(InputIterator, InputIterator, Compare, Container, Allocator) 1973894a8a4SArthur O'Dwyer -> priority_queue<typename Container::value_type, Container, Compare>; 1983894a8a4SArthur O'Dwyer 1993e519524SHoward Hinnanttemplate <class T, class Container, class Compare> 2003e519524SHoward Hinnant void swap(priority_queue<T, Container, Compare>& x, 2016971d826SHoward Hinnant priority_queue<T, Container, Compare>& y) 2026971d826SHoward Hinnant noexcept(noexcept(x.swap(y))); 2033e519524SHoward Hinnant 2043e519524SHoward Hinnant} // std 2053e519524SHoward Hinnant 2063e519524SHoward Hinnant*/ 2073e519524SHoward Hinnant 2083e519524SHoward Hinnant#include <__config> 209050b064fSChristopher Di Bella#include <__memory/uses_allocator.h> 2106adbc83eSChristopher Di Bella#include <__utility/forward.h> 211bfbd73f8SArthur O'Dwyer#include <algorithm> 2122d0f1fa4SArthur O'Dwyer#include <compare> 2133e519524SHoward Hinnant#include <deque> 2143e519524SHoward Hinnant#include <functional> 215bfbd73f8SArthur O'Dwyer#include <vector> 2163e519524SHoward Hinnant 217073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 2183e519524SHoward Hinnant#pragma GCC system_header 219073458b1SHoward Hinnant#endif 2203e519524SHoward Hinnant 2213e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 2223e519524SHoward Hinnant 223e2f2d1edSEric Fiseliertemplate <class _Tp, class _Container = deque<_Tp> > class _LIBCPP_TEMPLATE_VIS queue; 2243e519524SHoward Hinnant 2253e519524SHoward Hinnanttemplate <class _Tp, class _Container> 226aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2273e519524SHoward Hinnantbool 2283e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2293e519524SHoward Hinnant 2303e519524SHoward Hinnanttemplate <class _Tp, class _Container> 231aeb85680SHoward Hinnant_LIBCPP_INLINE_VISIBILITY 2323e519524SHoward Hinnantbool 2333e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); 2343e519524SHoward Hinnant 2353afa22a3SMarshall Clowtemplate <class _Tp, class _Container /*= deque<_Tp>*/> 236e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS queue 2373e519524SHoward Hinnant{ 2383e519524SHoward Hinnantpublic: 2393e519524SHoward Hinnant typedef _Container container_type; 2403e519524SHoward Hinnant typedef typename container_type::value_type value_type; 2413e519524SHoward Hinnant typedef typename container_type::reference reference; 2423e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 2433e519524SHoward Hinnant typedef typename container_type::size_type size_type; 244c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 2453e519524SHoward Hinnant 2463e519524SHoward Hinnantprotected: 2473e519524SHoward Hinnant container_type c; 2483e519524SHoward Hinnant 2493e519524SHoward Hinnantpublic: 250392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2516971d826SHoward Hinnant queue() 2526971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value) 2536971d826SHoward Hinnant : c() {} 2546971d826SHoward Hinnant 2556971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2566971d826SHoward Hinnant queue(const queue& __q) : c(__q.c) {} 2576971d826SHoward Hinnant 258f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 259f5427b26SEric Fiselier queue& operator=(const queue& __q) {c = __q.c; return *this;} 260f5427b26SEric Fiselier 261f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2626971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2636971d826SHoward Hinnant queue(queue&& __q) 2646971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value) 265ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)) {} 2666971d826SHoward Hinnant 2676971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2686971d826SHoward Hinnant queue& operator=(queue&& __q) 2696971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value) 270ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); return *this;} 271f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 2726971d826SHoward Hinnant 273392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2743e519524SHoward Hinnant explicit queue(const container_type& __c) : c(__c) {} 275f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 276392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 277ce48a113SHoward Hinnant explicit queue(container_type&& __c) : c(_VSTD::move(__c)) {} 278f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 2793e519524SHoward Hinnant template <class _Alloc> 280392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2813e519524SHoward Hinnant explicit queue(const _Alloc& __a, 282199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) 2833e519524SHoward Hinnant : c(__a) {} 2843e519524SHoward Hinnant template <class _Alloc> 285392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2863e519524SHoward Hinnant queue(const queue& __q, const _Alloc& __a, 287199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) 2883e519524SHoward Hinnant : c(__q.c, __a) {} 2893e519524SHoward Hinnant template <class _Alloc> 290392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2913e519524SHoward Hinnant queue(const container_type& __c, const _Alloc& __a, 292199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) 2933e519524SHoward Hinnant : c(__c, __a) {} 294f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 2953e519524SHoward Hinnant template <class _Alloc> 296392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 2973e519524SHoward Hinnant queue(container_type&& __c, const _Alloc& __a, 298199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) 299ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a) {} 3003e519524SHoward Hinnant template <class _Alloc> 301392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3023e519524SHoward Hinnant queue(queue&& __q, const _Alloc& __a, 303199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0) 304ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a) {} 3053e519524SHoward Hinnant 306f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 3073e519524SHoward Hinnant 30872c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 3093e519524SHoward Hinnant bool empty() const {return c.empty();} 310392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3113e519524SHoward Hinnant size_type size() const {return c.size();} 3123e519524SHoward Hinnant 313392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3143e519524SHoward Hinnant reference front() {return c.front();} 315392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3163e519524SHoward Hinnant const_reference front() const {return c.front();} 317392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3183e519524SHoward Hinnant reference back() {return c.back();} 319392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3203e519524SHoward Hinnant const_reference back() const {return c.back();} 3213e519524SHoward Hinnant 322392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3233e519524SHoward Hinnant void push(const value_type& __v) {c.push_back(__v);} 324f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 325392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 326ce48a113SHoward Hinnant void push(value_type&& __v) {c.push_back(_VSTD::move(__v));} 3273e519524SHoward Hinnant template <class... _Args> 328392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 32963b560beSMarshall Clow#if _LIBCPP_STD_VER > 14 330e34f5ffeSMarshall Clow decltype(auto) emplace(_Args&&... __args) 3310e411641SEric Fiselier { return c.emplace_back(_VSTD::forward<_Args>(__args)...);} 33263b560beSMarshall Clow#else 33363b560beSMarshall Clow void emplace(_Args&&... __args) 33463b560beSMarshall Clow { c.emplace_back(_VSTD::forward<_Args>(__args)...);} 33563b560beSMarshall Clow#endif 336f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 337392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3383e519524SHoward Hinnant void pop() {c.pop_front();} 3393e519524SHoward Hinnant 340392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3413e519524SHoward Hinnant void swap(queue& __q) 3426971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value) 3433e519524SHoward Hinnant { 344ce48a113SHoward Hinnant using _VSTD::swap; 3453e519524SHoward Hinnant swap(c, __q.c); 3463e519524SHoward Hinnant } 3473e519524SHoward Hinnant 3483e519524SHoward Hinnant template <class _T1, class _C1> 3493e519524SHoward Hinnant friend 350392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3513e519524SHoward Hinnant bool 3523e519524SHoward Hinnant operator==(const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3533e519524SHoward Hinnant 3543e519524SHoward Hinnant template <class _T1, class _C1> 3553e519524SHoward Hinnant friend 356392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 3573e519524SHoward Hinnant bool 3583e519524SHoward Hinnant operator< (const queue<_T1, _C1>& __x,const queue<_T1, _C1>& __y); 3593e519524SHoward Hinnant}; 3603e519524SHoward Hinnant 36101666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 3625b8b8b5dSMarshall Clowtemplate<class _Container, 363*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 3645b8b8b5dSMarshall Clow> 3655b8b8b5dSMarshall Clowqueue(_Container) 3665b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 3675b8b8b5dSMarshall Clow 3685b8b8b5dSMarshall Clowtemplate<class _Container, 3695b8b8b5dSMarshall Clow class _Alloc, 370*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 371*4e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 3725b8b8b5dSMarshall Clow> 3735b8b8b5dSMarshall Clowqueue(_Container, _Alloc) 3745b8b8b5dSMarshall Clow -> queue<typename _Container::value_type, _Container>; 3755b8b8b5dSMarshall Clow#endif 3765b8b8b5dSMarshall Clow 3773e519524SHoward Hinnanttemplate <class _Tp, class _Container> 378392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3793e519524SHoward Hinnantbool 3803e519524SHoward Hinnantoperator==(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3813e519524SHoward Hinnant{ 3823e519524SHoward Hinnant return __x.c == __y.c; 3833e519524SHoward Hinnant} 3843e519524SHoward Hinnant 3853e519524SHoward Hinnanttemplate <class _Tp, class _Container> 386392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3873e519524SHoward Hinnantbool 3883e519524SHoward Hinnantoperator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3893e519524SHoward Hinnant{ 3903e519524SHoward Hinnant return __x.c < __y.c; 3913e519524SHoward Hinnant} 3923e519524SHoward Hinnant 3933e519524SHoward Hinnanttemplate <class _Tp, class _Container> 394392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3953e519524SHoward Hinnantbool 3963e519524SHoward Hinnantoperator!=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 3973e519524SHoward Hinnant{ 3983e519524SHoward Hinnant return !(__x == __y); 3993e519524SHoward Hinnant} 4003e519524SHoward Hinnant 4013e519524SHoward Hinnanttemplate <class _Tp, class _Container> 402392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4033e519524SHoward Hinnantbool 4043e519524SHoward Hinnantoperator> (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4053e519524SHoward Hinnant{ 4063e519524SHoward Hinnant return __y < __x; 4073e519524SHoward Hinnant} 4083e519524SHoward Hinnant 4093e519524SHoward Hinnanttemplate <class _Tp, class _Container> 410392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4113e519524SHoward Hinnantbool 4123e519524SHoward Hinnantoperator>=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4133e519524SHoward Hinnant{ 4143e519524SHoward Hinnant return !(__x < __y); 4153e519524SHoward Hinnant} 4163e519524SHoward Hinnant 4173e519524SHoward Hinnanttemplate <class _Tp, class _Container> 418392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 4193e519524SHoward Hinnantbool 4203e519524SHoward Hinnantoperator<=(const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y) 4213e519524SHoward Hinnant{ 4223e519524SHoward Hinnant return !(__y < __x); 4233e519524SHoward Hinnant} 4243e519524SHoward Hinnant 4253e519524SHoward Hinnanttemplate <class _Tp, class _Container> 426392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 427199d2ebeSArthur O'Dwyer_EnableIf<__is_swappable<_Container>::value, void> 4283e519524SHoward Hinnantswap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) 4296971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 4303e519524SHoward Hinnant{ 4313e519524SHoward Hinnant __x.swap(__y); 4323e519524SHoward Hinnant} 4333e519524SHoward Hinnant 4343e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Alloc> 435e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> 4363e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 4373e519524SHoward Hinnant{ 4383e519524SHoward Hinnant}; 4393e519524SHoward Hinnant 4403e519524SHoward Hinnanttemplate <class _Tp, class _Container = vector<_Tp>, 4413e519524SHoward Hinnant class _Compare = less<typename _Container::value_type> > 442e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS priority_queue 4433e519524SHoward Hinnant{ 4443e519524SHoward Hinnantpublic: 4453e519524SHoward Hinnant typedef _Container container_type; 4463e519524SHoward Hinnant typedef _Compare value_compare; 4473e519524SHoward Hinnant typedef typename container_type::value_type value_type; 4483e519524SHoward Hinnant typedef typename container_type::reference reference; 4493e519524SHoward Hinnant typedef typename container_type::const_reference const_reference; 4503e519524SHoward Hinnant typedef typename container_type::size_type size_type; 451c1fe2c43SMarshall Clow static_assert((is_same<_Tp, value_type>::value), "" ); 4523e519524SHoward Hinnant 4533e519524SHoward Hinnantprotected: 4543e519524SHoward Hinnant container_type c; 4553e519524SHoward Hinnant value_compare comp; 4563e519524SHoward Hinnant 4573e519524SHoward Hinnantpublic: 458392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4596971d826SHoward Hinnant priority_queue() 4606971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_default_constructible<container_type>::value && 4616971d826SHoward Hinnant is_nothrow_default_constructible<value_compare>::value) 4626971d826SHoward Hinnant : c(), comp() {} 4636971d826SHoward Hinnant 4646971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4656971d826SHoward Hinnant priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} 4666971d826SHoward Hinnant 467f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 468f5427b26SEric Fiselier priority_queue& operator=(const priority_queue& __q) 469f5427b26SEric Fiselier {c = __q.c; comp = __q.comp; return *this;} 470f5427b26SEric Fiselier 471f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 4726971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4736971d826SHoward Hinnant priority_queue(priority_queue&& __q) 4746971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_constructible<container_type>::value && 4756971d826SHoward Hinnant is_nothrow_move_constructible<value_compare>::value) 476ce48a113SHoward Hinnant : c(_VSTD::move(__q.c)), comp(_VSTD::move(__q.comp)) {} 4776971d826SHoward Hinnant 4786971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4796971d826SHoward Hinnant priority_queue& operator=(priority_queue&& __q) 4806971d826SHoward Hinnant _NOEXCEPT_(is_nothrow_move_assignable<container_type>::value && 4816971d826SHoward Hinnant is_nothrow_move_assignable<value_compare>::value) 482ce48a113SHoward Hinnant {c = _VSTD::move(__q.c); comp = _VSTD::move(__q.comp); return *this;} 483f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 4846971d826SHoward Hinnant 4856971d826SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 4866971d826SHoward Hinnant explicit priority_queue(const value_compare& __comp) 4873e519524SHoward Hinnant : c(), comp(__comp) {} 488cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 4893e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c); 490f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 491cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 492a11f8b1aSMarek Kurdej priority_queue(const value_compare& __comp, container_type&& __c); 4933e519524SHoward Hinnant#endif 4943894a8a4SArthur O'Dwyer template <class _InputIter, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 495cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 4963e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 4973e519524SHoward Hinnant const value_compare& __comp = value_compare()); 4983894a8a4SArthur O'Dwyer template <class _InputIter, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 499cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5003e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5013e519524SHoward Hinnant const value_compare& __comp, const container_type& __c); 502f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5033894a8a4SArthur O'Dwyer template <class _InputIter, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 504cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5053e519524SHoward Hinnant priority_queue(_InputIter __f, _InputIter __l, 5063e519524SHoward Hinnant const value_compare& __comp, container_type&& __c); 507f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5083e519524SHoward Hinnant template <class _Alloc> 509cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5103e519524SHoward Hinnant explicit priority_queue(const _Alloc& __a, 511199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5123e519524SHoward Hinnant template <class _Alloc> 513cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5143e519524SHoward Hinnant priority_queue(const value_compare& __comp, const _Alloc& __a, 515199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5163e519524SHoward Hinnant template <class _Alloc> 517cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5183e519524SHoward Hinnant priority_queue(const value_compare& __comp, const container_type& __c, 5193e519524SHoward Hinnant const _Alloc& __a, 520199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5213e519524SHoward Hinnant template <class _Alloc> 522cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5233e519524SHoward Hinnant priority_queue(const priority_queue& __q, const _Alloc& __a, 524199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 525f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 5263e519524SHoward Hinnant template <class _Alloc> 527cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5283e519524SHoward Hinnant priority_queue(const value_compare& __comp, container_type&& __c, 5293e519524SHoward Hinnant const _Alloc& __a, 530199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5313e519524SHoward Hinnant template <class _Alloc> 532cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5333e519524SHoward Hinnant priority_queue(priority_queue&& __q, const _Alloc& __a, 534199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 535f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 5363e519524SHoward Hinnant 5373894a8a4SArthur O'Dwyer template <class _InputIter, class _Alloc, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 5383894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5393894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a, 5403894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5413894a8a4SArthur O'Dwyer 5423894a8a4SArthur O'Dwyer template <class _InputIter, class _Alloc, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 5433894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5443894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5453894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 5463894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5473894a8a4SArthur O'Dwyer 5483894a8a4SArthur O'Dwyer template <class _InputIter, class _Alloc, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 5493894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5503894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5513894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 5523894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5533894a8a4SArthur O'Dwyer 5543894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 5553894a8a4SArthur O'Dwyer template <class _InputIter, class _Alloc, class = _EnableIf<__is_cpp17_input_iterator<_InputIter>::value> > 5563894a8a4SArthur O'Dwyer _LIBCPP_INLINE_VISIBILITY 5573894a8a4SArthur O'Dwyer priority_queue(_InputIter __f, _InputIter __l, 5583894a8a4SArthur O'Dwyer const value_compare& __comp, container_type&& __c, const _Alloc& __a, 5593894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>* = 0); 5603894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 5613894a8a4SArthur O'Dwyer 56272c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 5633e519524SHoward Hinnant bool empty() const {return c.empty();} 564392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5653e519524SHoward Hinnant size_type size() const {return c.size();} 566392183f9SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 5673e519524SHoward Hinnant const_reference top() const {return c.front();} 5683e519524SHoward Hinnant 569cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5703e519524SHoward Hinnant void push(const value_type& __v); 571f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 572cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5733e519524SHoward Hinnant void push(value_type&& __v); 574f5427b26SEric Fiselier template <class... _Args> 575f5427b26SEric Fiselier _LIBCPP_INLINE_VISIBILITY 576f5427b26SEric Fiselier void emplace(_Args&&... __args); 577f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 578cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5793e519524SHoward Hinnant void pop(); 5803e519524SHoward Hinnant 581cd31b434SEvgeniy Stepanov _LIBCPP_INLINE_VISIBILITY 5826971d826SHoward Hinnant void swap(priority_queue& __q) 5836971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 5846971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value); 5853e519524SHoward Hinnant}; 5863e519524SHoward Hinnant 58701666904SLouis Dionne#if _LIBCPP_STD_VER >= 17 5885b8b8b5dSMarshall Clowtemplate <class _Compare, 5895b8b8b5dSMarshall Clow class _Container, 590*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 591*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 5925b8b8b5dSMarshall Clow> 5935b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container) 5945b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 5955b8b8b5dSMarshall Clow 5965b8b8b5dSMarshall Clowtemplate<class _InputIterator, 597199d2ebeSArthur O'Dwyer class _Compare = less<__iter_value_type<_InputIterator>>, 598199d2ebeSArthur O'Dwyer class _Container = vector<__iter_value_type<_InputIterator>>, 599*4e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 600*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 601*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value> 6025b8b8b5dSMarshall Clow> 6035b8b8b5dSMarshall Clowpriority_queue(_InputIterator, _InputIterator, _Compare = _Compare(), _Container = _Container()) 604199d2ebeSArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, _Container, _Compare>; 6055b8b8b5dSMarshall Clow 6065b8b8b5dSMarshall Clowtemplate<class _Compare, 6075b8b8b5dSMarshall Clow class _Container, 6085b8b8b5dSMarshall Clow class _Alloc, 609*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 610*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 611*4e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6125b8b8b5dSMarshall Clow> 6135b8b8b5dSMarshall Clowpriority_queue(_Compare, _Container, _Alloc) 6145b8b8b5dSMarshall Clow -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6153894a8a4SArthur O'Dwyer 6163894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Allocator, 617*4e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 618*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6193894a8a4SArthur O'Dwyer> 6203894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Allocator) 6213894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6223894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, 6233894a8a4SArthur O'Dwyer less<__iter_value_type<_InputIterator>>>; 6243894a8a4SArthur O'Dwyer 6253894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Allocator, 626*4e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 627*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 628*4e0ea2cfSLouis Dionne class = enable_if_t<__is_allocator<_Allocator>::value> 6293894a8a4SArthur O'Dwyer> 6303894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Allocator) 6313894a8a4SArthur O'Dwyer -> priority_queue<__iter_value_type<_InputIterator>, 6323894a8a4SArthur O'Dwyer vector<__iter_value_type<_InputIterator>, _Allocator>, _Compare>; 6333894a8a4SArthur O'Dwyer 6343894a8a4SArthur O'Dwyertemplate<class _InputIterator, class _Compare, class _Container, class _Alloc, 635*4e0ea2cfSLouis Dionne class = enable_if_t<__is_cpp17_input_iterator<_InputIterator>::value>, 636*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Compare>::value>, 637*4e0ea2cfSLouis Dionne class = enable_if_t<!__is_allocator<_Container>::value>, 638*4e0ea2cfSLouis Dionne class = enable_if_t<uses_allocator<_Container, _Alloc>::value> 6393894a8a4SArthur O'Dwyer> 6403894a8a4SArthur O'Dwyerpriority_queue(_InputIterator, _InputIterator, _Compare, _Container, _Alloc) 6413894a8a4SArthur O'Dwyer -> priority_queue<typename _Container::value_type, _Container, _Compare>; 6425b8b8b5dSMarshall Clow#endif 6435b8b8b5dSMarshall Clow 6443e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 645cd31b434SEvgeniy Stepanovinline 6463e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, 6473e519524SHoward Hinnant const container_type& __c) 6483e519524SHoward Hinnant : c(__c), 6493e519524SHoward Hinnant comp(__comp) 6503e519524SHoward Hinnant{ 651ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6523e519524SHoward Hinnant} 6533e519524SHoward Hinnant 654f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 6553e519524SHoward Hinnant 6563e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 657cd31b434SEvgeniy Stepanovinline 6583e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 6593e519524SHoward Hinnant container_type&& __c) 660ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 6613e519524SHoward Hinnant comp(__comp) 6623e519524SHoward Hinnant{ 663ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6643e519524SHoward Hinnant} 6653e519524SHoward Hinnant 666f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 6673e519524SHoward Hinnant 6683e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 6693894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 670cd31b434SEvgeniy Stepanovinline 6713e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6723e519524SHoward Hinnant const value_compare& __comp) 6733e519524SHoward Hinnant : c(__f, __l), 6743e519524SHoward Hinnant comp(__comp) 6753e519524SHoward Hinnant{ 676ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6773e519524SHoward Hinnant} 6783e519524SHoward Hinnant 6793e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 6803894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 681cd31b434SEvgeniy Stepanovinline 6823e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6833e519524SHoward Hinnant const value_compare& __comp, 6843e519524SHoward Hinnant const container_type& __c) 6853e519524SHoward Hinnant : c(__c), 6863e519524SHoward Hinnant comp(__comp) 6873e519524SHoward Hinnant{ 6883e519524SHoward Hinnant c.insert(c.end(), __f, __l); 689ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 6903e519524SHoward Hinnant} 6913e519524SHoward Hinnant 692f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 6933e519524SHoward Hinnant 6943e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 6953894a8a4SArthur O'Dwyertemplate <class _InputIter, class> 696cd31b434SEvgeniy Stepanovinline 6973e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, 6983e519524SHoward Hinnant const value_compare& __comp, 6993e519524SHoward Hinnant container_type&& __c) 700ce48a113SHoward Hinnant : c(_VSTD::move(__c)), 7013e519524SHoward Hinnant comp(__comp) 7023e519524SHoward Hinnant{ 7033e519524SHoward Hinnant c.insert(c.end(), __f, __l); 704ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7053e519524SHoward Hinnant} 7063e519524SHoward Hinnant 707f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 7083e519524SHoward Hinnant 7093e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7103e519524SHoward Hinnanttemplate <class _Alloc> 711cd31b434SEvgeniy Stepanovinline 7123e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a, 713199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 7143e519524SHoward Hinnant : c(__a) 7153e519524SHoward Hinnant{ 7163e519524SHoward Hinnant} 7173e519524SHoward Hinnant 7183e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7193e519524SHoward Hinnanttemplate <class _Alloc> 720cd31b434SEvgeniy Stepanovinline 7213e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7223e519524SHoward Hinnant const _Alloc& __a, 723199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 7243e519524SHoward Hinnant : c(__a), 7253e519524SHoward Hinnant comp(__comp) 7263e519524SHoward Hinnant{ 7273e519524SHoward Hinnant} 7283e519524SHoward Hinnant 7293e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7303e519524SHoward Hinnanttemplate <class _Alloc> 731cd31b434SEvgeniy Stepanovinline 7323e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7333e519524SHoward Hinnant const container_type& __c, 7343e519524SHoward Hinnant const _Alloc& __a, 735199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 7363e519524SHoward Hinnant : c(__c, __a), 7373e519524SHoward Hinnant comp(__comp) 7383e519524SHoward Hinnant{ 739ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7403e519524SHoward Hinnant} 7413e519524SHoward Hinnant 7423e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7433e519524SHoward Hinnanttemplate <class _Alloc> 744cd31b434SEvgeniy Stepanovinline 7453e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, 7463e519524SHoward Hinnant const _Alloc& __a, 747199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 7483e519524SHoward Hinnant : c(__q.c, __a), 7493e519524SHoward Hinnant comp(__q.comp) 7503e519524SHoward Hinnant{ 7513e519524SHoward Hinnant} 7523e519524SHoward Hinnant 753f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 7543e519524SHoward Hinnant 7553e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7563e519524SHoward Hinnanttemplate <class _Alloc> 757cd31b434SEvgeniy Stepanovinline 7583e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, 7593e519524SHoward Hinnant container_type&& __c, 7603e519524SHoward Hinnant const _Alloc& __a, 761199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 762ce48a113SHoward Hinnant : c(_VSTD::move(__c), __a), 7633e519524SHoward Hinnant comp(__comp) 7643e519524SHoward Hinnant{ 765ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7663e519524SHoward Hinnant} 7673e519524SHoward Hinnant 7683e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 7693e519524SHoward Hinnanttemplate <class _Alloc> 770cd31b434SEvgeniy Stepanovinline 7713e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::priority_queue(priority_queue&& __q, 7723e519524SHoward Hinnant const _Alloc& __a, 773199d2ebeSArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 774ce48a113SHoward Hinnant : c(_VSTD::move(__q.c), __a), 775ce48a113SHoward Hinnant comp(_VSTD::move(__q.comp)) 7763e519524SHoward Hinnant{ 7773894a8a4SArthur O'Dwyer} 7783894a8a4SArthur O'Dwyer 7793894a8a4SArthur O'Dwyer#endif // _LIBCPP_CXX03_LANG 7803894a8a4SArthur O'Dwyer 7813894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 7823894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 7833894a8a4SArthur O'Dwyerinline 7843894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 7853894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const _Alloc& __a, 7863894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 7873894a8a4SArthur O'Dwyer : c(__f, __l, __a), 7883894a8a4SArthur O'Dwyer comp() 7893894a8a4SArthur O'Dwyer{ 790ce48a113SHoward Hinnant _VSTD::make_heap(c.begin(), c.end(), comp); 7913e519524SHoward Hinnant} 7923e519524SHoward Hinnant 7933894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 7943894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 7953894a8a4SArthur O'Dwyerinline 7963894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 7973894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 7983894a8a4SArthur O'Dwyer const value_compare& __comp, const _Alloc& __a, 7993894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 8003894a8a4SArthur O'Dwyer : c(__f, __l, __a), 8013894a8a4SArthur O'Dwyer comp(__comp) 8023894a8a4SArthur O'Dwyer{ 8033894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8043894a8a4SArthur O'Dwyer} 8053894a8a4SArthur O'Dwyer 8063894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8073894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8083894a8a4SArthur O'Dwyerinline 8093894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8103894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, 8113894a8a4SArthur O'Dwyer const value_compare& __comp, const container_type& __c, const _Alloc& __a, 8123894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 8133894a8a4SArthur O'Dwyer : c(__c, __a), 8143894a8a4SArthur O'Dwyer comp(__comp) 8153894a8a4SArthur O'Dwyer{ 8163894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8173894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8183894a8a4SArthur O'Dwyer} 8193894a8a4SArthur O'Dwyer 8203894a8a4SArthur O'Dwyer#ifndef _LIBCPP_CXX03_LANG 8213894a8a4SArthur O'Dwyertemplate <class _Tp, class _Container, class _Compare> 8223894a8a4SArthur O'Dwyertemplate <class _InputIter, class _Alloc, class> 8233894a8a4SArthur O'Dwyerinline 8243894a8a4SArthur O'Dwyerpriority_queue<_Tp, _Container, _Compare>::priority_queue( 8253894a8a4SArthur O'Dwyer _InputIter __f, _InputIter __l, const value_compare& __comp, 8263894a8a4SArthur O'Dwyer container_type&& __c, const _Alloc& __a, 8273894a8a4SArthur O'Dwyer _EnableIf<uses_allocator<container_type, _Alloc>::value>*) 8283894a8a4SArthur O'Dwyer : c(_VSTD::move(__c), __a), 8293894a8a4SArthur O'Dwyer comp(__comp) 8303894a8a4SArthur O'Dwyer{ 8313894a8a4SArthur O'Dwyer c.insert(c.end(), __f, __l); 8323894a8a4SArthur O'Dwyer _VSTD::make_heap(c.begin(), c.end(), comp); 8333894a8a4SArthur O'Dwyer} 834f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8353e519524SHoward Hinnant 8363e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 837cd31b434SEvgeniy Stepanovinline 8383e519524SHoward Hinnantvoid 8393e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) 8403e519524SHoward Hinnant{ 8413e519524SHoward Hinnant c.push_back(__v); 842ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8433e519524SHoward Hinnant} 8443e519524SHoward Hinnant 845f5427b26SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 8463e519524SHoward Hinnant 8473e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 848cd31b434SEvgeniy Stepanovinline 8493e519524SHoward Hinnantvoid 8503e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::push(value_type&& __v) 8513e519524SHoward Hinnant{ 852ce48a113SHoward Hinnant c.push_back(_VSTD::move(__v)); 853ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8543e519524SHoward Hinnant} 8553e519524SHoward Hinnant 8563e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 8573e519524SHoward Hinnanttemplate <class... _Args> 858cd31b434SEvgeniy Stepanovinline 8593e519524SHoward Hinnantvoid 8603e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::emplace(_Args&&... __args) 8613e519524SHoward Hinnant{ 862ce48a113SHoward Hinnant c.emplace_back(_VSTD::forward<_Args>(__args)...); 863ce48a113SHoward Hinnant _VSTD::push_heap(c.begin(), c.end(), comp); 8643e519524SHoward Hinnant} 8653e519524SHoward Hinnant 866f5427b26SEric Fiselier#endif // _LIBCPP_CXX03_LANG 8673e519524SHoward Hinnant 8683e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 869cd31b434SEvgeniy Stepanovinline 8703e519524SHoward Hinnantvoid 8713e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::pop() 8723e519524SHoward Hinnant{ 873ce48a113SHoward Hinnant _VSTD::pop_heap(c.begin(), c.end(), comp); 8743e519524SHoward Hinnant c.pop_back(); 8753e519524SHoward Hinnant} 8763e519524SHoward Hinnant 8773e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 878cd31b434SEvgeniy Stepanovinline 8793e519524SHoward Hinnantvoid 8803e519524SHoward Hinnantpriority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) 8816971d826SHoward Hinnant _NOEXCEPT_(__is_nothrow_swappable<container_type>::value && 8826971d826SHoward Hinnant __is_nothrow_swappable<value_compare>::value) 8833e519524SHoward Hinnant{ 884ce48a113SHoward Hinnant using _VSTD::swap; 8853e519524SHoward Hinnant swap(c, __q.c); 8863e519524SHoward Hinnant swap(comp, __q.comp); 8873e519524SHoward Hinnant} 8883e519524SHoward Hinnant 8893e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare> 890392183f9SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 891199d2ebeSArthur O'Dwyer_EnableIf< 892199d2ebeSArthur O'Dwyer __is_swappable<_Container>::value && __is_swappable<_Compare>::value, 8933e519524SHoward Hinnant void 894199d2ebeSArthur O'Dwyer> 8953e519524SHoward Hinnantswap(priority_queue<_Tp, _Container, _Compare>& __x, 8963e519524SHoward Hinnant priority_queue<_Tp, _Container, _Compare>& __y) 8976971d826SHoward Hinnant _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) 8983e519524SHoward Hinnant{ 8993e519524SHoward Hinnant __x.swap(__y); 9003e519524SHoward Hinnant} 9013e519524SHoward Hinnant 9023e519524SHoward Hinnanttemplate <class _Tp, class _Container, class _Compare, class _Alloc> 903e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> 9043e519524SHoward Hinnant : public uses_allocator<_Container, _Alloc> 9053e519524SHoward Hinnant{ 9063e519524SHoward Hinnant}; 9073e519524SHoward Hinnant 9083e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 9093e519524SHoward Hinnant 9103e519524SHoward Hinnant#endif // _LIBCPP_QUEUE 911