| 1 |
// -*- C++ -*- |
| 2 |
//===----------------------------------------------------------------------===// |
| 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-exception |
| 7 |
// |
| 8 |
//===----------------------------------------------------------------------===// |
| 9 |
|
| 10 |
#ifndef _LIBCPP___CXX03_QUEUE |
| 11 |
#define _LIBCPP___CXX03_QUEUE |
| 12 |
|
| 13 |
/* |
| 14 |
queue synopsis |
| 15 |
|
| 16 |
namespace std |
| 17 |
{ |
| 18 |
|
| 19 |
template <class T, class Container = deque<T>> |
| 20 |
class queue |
| 21 |
{ |
| 22 |
public: |
| 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 |
|
| 29 |
protected: |
| 30 |
container_type c; |
| 31 |
|
| 32 |
public: |
| 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 InputIterator> |
| 45 |
queue(InputIterator first, InputIterator last); // since C++23 |
| 46 |
template<container-compatible-range<T> R> queue(from_range_t, R&& rg); // since C++23 |
| 47 |
template <class Alloc> |
| 48 |
explicit queue(const Alloc& a); |
| 49 |
template <class Alloc> |
| 50 |
queue(const container_type& c, const Alloc& a); |
| 51 |
template <class Alloc> |
| 52 |
queue(container_type&& c, const Alloc& a); |
| 53 |
template <class Alloc> |
| 54 |
queue(const queue& q, const Alloc& a); |
| 55 |
template <class Alloc> |
| 56 |
queue(queue&& q, const Alloc& a); |
| 57 |
template <class InputIterator, class Alloc> |
| 58 |
queue(InputIterator first, InputIterator last, const Alloc&); // since C++23 |
| 59 |
template<container-compatible-range<T> R, class Alloc> |
| 60 |
queue(from_range_t, R&& rg, const Alloc&); // since C++23 |
| 61 |
|
| 62 |
bool empty() const; |
| 63 |
size_type size() const; |
| 64 |
|
| 65 |
reference front(); |
| 66 |
const_reference front() const; |
| 67 |
reference back(); |
| 68 |
const_reference back() const; |
| 69 |
|
| 70 |
void push(const value_type& v); |
| 71 |
void push(value_type&& v); |
| 72 |
template<container-compatible-range<T> R> |
| 73 |
void push_range(R&& rg); // C++23 |
| 74 |
template <class... Args> reference emplace(Args&&... args); // reference in C++17 |
| 75 |
void pop(); |
| 76 |
|
| 77 |
void swap(queue& q) noexcept(is_nothrow_swappable_v<Container>) |
| 78 |
}; |
| 79 |
|
| 80 |
template<class Container> |
| 81 |
queue(Container) -> queue<typename Container::value_type, Container>; // C++17 |
| 82 |
|
| 83 |
template<class InputIterator> |
| 84 |
queue(InputIterator, InputIterator) -> queue<iter-value-type<InputIterator>>; // since C++23 |
| 85 |
|
| 86 |
template<ranges::input_range R> |
| 87 |
queue(from_range_t, R&&) -> queue<ranges::range_value_t<R>>; // since C++23 |
| 88 |
|
| 89 |
template<class Container, class Allocator> |
| 90 |
queue(Container, Allocator) -> queue<typename Container::value_type, Container>; // C++17 |
| 91 |
|
| 92 |
template<class InputIterator, class Allocator> |
| 93 |
queue(InputIterator, InputIterator, Allocator) |
| 94 |
-> queue<iter-value-type<InputIterator>, |
| 95 |
deque<iter-value-type<InputIterator>, Allocator>>; // since C++23 |
| 96 |
|
| 97 |
template<ranges::input_range R, class Allocator> |
| 98 |
queue(from_range_t, R&&, Allocator) |
| 99 |
-> queue<ranges::range_value_t<R>, deque<ranges::range_value_t<R>, Allocator>>; // since C++23 |
| 100 |
|
| 101 |
template <class T, class Container> |
| 102 |
bool operator==(const queue<T, Container>& x,const queue<T, Container>& y); |
| 103 |
|
| 104 |
template <class T, class Container> |
| 105 |
bool operator< (const queue<T, Container>& x,const queue<T, Container>& y); |
| 106 |
|
| 107 |
template <class T, class Container> |
| 108 |
bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 109 |
|
| 110 |
template <class T, class Container> |
| 111 |
bool operator> (const queue<T, Container>& x,const queue<T, Container>& y); |
| 112 |
|
| 113 |
template <class T, class Container> |
| 114 |
bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 115 |
|
| 116 |
template <class T, class Container> |
| 117 |
bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y); |
| 118 |
|
| 119 |
template<class T, three_way_comparable Container> |
| 120 |
compare_three_way_result_t<Container> |
| 121 |
operator<=>(const queue<T, Container>& x, const queue<T, Container>& y); // since C++20 |
| 122 |
|
| 123 |
template <class T, class Container> |
| 124 |
void swap(queue<T, Container>& x, queue<T, Container>& y) |
| 125 |
noexcept(noexcept(x.swap(y))); |
| 126 |
|
| 127 |
template <class T, class Container = vector<T>, |
| 128 |
class Compare = less<typename Container::value_type>> |
| 129 |
class priority_queue |
| 130 |
{ |
| 131 |
public: |
| 132 |
typedef Container container_type; |
| 133 |
typedef typename container_type::value_type value_type; |
| 134 |
typedef typename container_type::reference reference; |
| 135 |
typedef typename container_type::const_reference const_reference; |
| 136 |
typedef typename container_type::size_type size_type; |
| 137 |
|
| 138 |
protected: |
| 139 |
container_type c; |
| 140 |
Compare comp; |
| 141 |
|
| 142 |
public: |
| 143 |
priority_queue() : priority_queue(Compare()) {} // C++20 |
| 144 |
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {} |
| 145 |
priority_queue(const Compare& x, const Container&); |
| 146 |
explicit priority_queue(const Compare& x = Compare(), Container&& = Container()); // before C++20 |
| 147 |
priority_queue(const Compare& x, Container&&); // C++20 |
| 148 |
template <class InputIterator> |
| 149 |
priority_queue(InputIterator first, InputIterator last, |
| 150 |
const Compare& comp = Compare()); |
| 151 |
template <class InputIterator> |
| 152 |
priority_queue(InputIterator first, InputIterator last, |
| 153 |
const Compare& comp, const Container& c); |
| 154 |
template <class InputIterator> |
| 155 |
priority_queue(InputIterator first, InputIterator last, |
| 156 |
const Compare& comp, Container&& c); |
| 157 |
template <container-compatible-range<T> R> |
| 158 |
priority_queue(from_range_t, R&& rg, const Compare& x = Compare()); // since C++23 |
| 159 |
template <class Alloc> |
| 160 |
explicit priority_queue(const Alloc& a); |
| 161 |
template <class Alloc> |
| 162 |
priority_queue(const Compare& comp, const Alloc& a); |
| 163 |
template <class Alloc> |
| 164 |
priority_queue(const Compare& comp, const Container& c, |
| 165 |
const Alloc& a); |
| 166 |
template <class Alloc> |
| 167 |
priority_queue(const Compare& comp, Container&& c, |
| 168 |
const Alloc& a); |
| 169 |
template <class InputIterator> |
| 170 |
priority_queue(InputIterator first, InputIterator last, |
| 171 |
const Alloc& a); |
| 172 |
template <class InputIterator> |
| 173 |
priority_queue(InputIterator first, InputIterator last, |
| 174 |
const Compare& comp, const Alloc& a); |
| 175 |
template <class InputIterator> |
| 176 |
priority_queue(InputIterator first, InputIterator last, |
| 177 |
const Compare& comp, const Container& c, const Alloc& a); |
| 178 |
template <class InputIterator> |
| 179 |
priority_queue(InputIterator first, InputIterator last, |
| 180 |
const Compare& comp, Container&& c, const Alloc& a); |
| 181 |
template <container-compatible-range<T> R, class Alloc> |
| 182 |
priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&); // since C++23 |
| 183 |
template <container-compatible-range<T> R, class Alloc> |
| 184 |
priority_queue(from_range_t, R&& rg, const Alloc&); // since C++23 |
| 185 |
template <class Alloc> |
| 186 |
priority_queue(const priority_queue& q, const Alloc& a); |
| 187 |
template <class Alloc> |
| 188 |
priority_queue(priority_queue&& q, const Alloc& a); |
| 189 |
|
| 190 |
bool empty() const; |
| 191 |
size_type size() const; |
| 192 |
const_reference top() const; |
| 193 |
|
| 194 |
void push(const value_type& v); |
| 195 |
void push(value_type&& v); |
| 196 |
template<container-compatible-range<T> R> |
| 197 |
void push_range(R&& rg); // C++23 |
| 198 |
template <class... Args> void emplace(Args&&... args); |
| 199 |
void pop(); |
| 200 |
|
| 201 |
void swap(priority_queue& q) |
| 202 |
noexcept(is_nothrow_swappable_v<Container> && |
| 203 |
is_nothrow_swappable_v<Comp>) |
| 204 |
}; |
| 205 |
|
| 206 |
template <class Compare, class Container> |
| 207 |
priority_queue(Compare, Container) |
| 208 |
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17 |
| 209 |
|
| 210 |
template<class InputIterator, |
| 211 |
class Compare = less<iter-value-type<InputIterator>>, |
| 212 |
class Container = vector<iter-value-type<InputIterator>>> |
| 213 |
priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container()) |
| 214 |
-> priority_queue<iter-value-type<InputIterator>, Container, Compare>; // C++17 |
| 215 |
|
| 216 |
template<ranges::input_range R, class Compare = less<ranges::range_value_t<R>>> |
| 217 |
priority_queue(from_range_t, R&&, Compare = Compare()) |
| 218 |
-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>>, Compare>; // C++23 |
| 219 |
|
| 220 |
template<class Compare, class Container, class Allocator> |
| 221 |
priority_queue(Compare, Container, Allocator) |
| 222 |
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17 |
| 223 |
|
| 224 |
template<class InputIterator, class Allocator> |
| 225 |
priority_queue(InputIterator, InputIterator, Allocator) |
| 226 |
-> priority_queue<iter-value-type<InputIterator>, |
| 227 |
vector<iter-value-type<InputIterator>, Allocator>, |
| 228 |
less<iter-value-type<InputIterator>>>; // C++17 |
| 229 |
|
| 230 |
template<class InputIterator, class Compare, class Allocator> |
| 231 |
priority_queue(InputIterator, InputIterator, Compare, Allocator) |
| 232 |
-> priority_queue<iter-value-type<InputIterator>, |
| 233 |
vector<iter-value-type<InputIterator>, Allocator>, Compare>; // C++17 |
| 234 |
|
| 235 |
template<class InputIterator, class Compare, class Container, class Allocator> |
| 236 |
priority_queue(InputIterator, InputIterator, Compare, Container, Allocator) |
| 237 |
-> priority_queue<typename Container::value_type, Container, Compare>; // C++17 |
| 238 |
|
| 239 |
template<ranges::input_range R, class Compare, class Allocator> |
| 240 |
priority_queue(from_range_t, R&&, Compare, Allocator) |
| 241 |
-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>, |
| 242 |
Compare>; // C++23 |
| 243 |
|
| 244 |
template<ranges::input_range R, class Allocator> |
| 245 |
priority_queue(from_range_t, R&&, Allocator) |
| 246 |
-> priority_queue<ranges::range_value_t<R>, vector<ranges::range_value_t<R>, Allocator>>; // C++23 |
| 247 |
|
| 248 |
template <class T, class Container, class Compare> |
| 249 |
void swap(priority_queue<T, Container, Compare>& x, |
| 250 |
priority_queue<T, Container, Compare>& y) |
| 251 |
noexcept(noexcept(x.swap(y))); |
| 252 |
|
| 253 |
} // std |
| 254 |
|
| 255 |
*/ |
| 256 |
|
| 257 |
#include <__cxx03/__algorithm/make_heap.h> |
| 258 |
#include <__cxx03/__algorithm/pop_heap.h> |
| 259 |
#include <__cxx03/__algorithm/push_heap.h> |
| 260 |
#include <__cxx03/__config> |
| 261 |
#include <__cxx03/__functional/operations.h> |
| 262 |
#include <__cxx03/__fwd/deque.h> |
| 263 |
#include <__cxx03/__fwd/queue.h> |
| 264 |
#include <__cxx03/__iterator/back_insert_iterator.h> |
| 265 |
#include <__cxx03/__iterator/iterator_traits.h> |
| 266 |
#include <__cxx03/__memory/uses_allocator.h> |
| 267 |
#include <__cxx03/__utility/forward.h> |
| 268 |
#include <__cxx03/deque> |
| 269 |
#include <__cxx03/vector> |
| 270 |
#include <__cxx03/version> |
| 271 |
|
| 272 |
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 273 |
# pragma GCC system_header |
| 274 |
#endif |
| 275 |
|
| 276 |
_LIBCPP_PUSH_MACROS |
| 277 |
#include <__cxx03/__undef_macros> |
| 278 |
|
| 279 |
_LIBCPP_BEGIN_NAMESPACE_STD |
| 280 |
|
| 281 |
template <class _Tp, class _Container> |
| 282 |
_LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); |
| 283 |
|
| 284 |
template <class _Tp, class _Container> |
| 285 |
_LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y); |
| 286 |
|
| 287 |
template <class _Tp, class _Container /*= deque<_Tp>*/> |
| 288 |
class _LIBCPP_TEMPLATE_VIS queue { |
| 289 |
public: |
| 290 |
typedef _Container container_type; |
| 291 |
typedef typename container_type::value_type value_type; |
| 292 |
typedef typename container_type::reference reference; |
| 293 |
typedef typename container_type::const_reference const_reference; |
| 294 |
typedef typename container_type::size_type size_type; |
| 295 |
static_assert(is_same<_Tp, value_type>::value, ""); |
| 296 |
|
| 297 |
protected: |
| 298 |
container_type c; |
| 299 |
|
| 300 |
public: |
| 301 |
_LIBCPP_HIDE_FROM_ABI queue() : c() {} |
| 302 |
|
| 303 |
_LIBCPP_HIDE_FROM_ABI queue(const queue& __q) : c(__q.c) {} |
| 304 |
|
| 305 |
_LIBCPP_HIDE_FROM_ABI queue& operator=(const queue& __q) { |
| 306 |
c = __q.c; |
| 307 |
return *this; |
| 308 |
} |
| 309 |
|
| 310 |
_LIBCPP_HIDE_FROM_ABI explicit queue(const container_type& __c) : c(__c) {} |
| 311 |
|
| 312 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 313 |
_LIBCPP_HIDE_FROM_ABI explicit queue(const _Alloc& __a) : c(__a) {} |
| 314 |
|
| 315 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 316 |
_LIBCPP_HIDE_FROM_ABI queue(const queue& __q, const _Alloc& __a) : c(__q.c, __a) {} |
| 317 |
|
| 318 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 319 |
_LIBCPP_HIDE_FROM_ABI queue(const container_type& __c, const _Alloc& __a) : c(__c, __a) {} |
| 320 |
|
| 321 |
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 322 |
_LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 323 |
|
| 324 |
_LIBCPP_HIDE_FROM_ABI reference front() { return c.front(); } |
| 325 |
_LIBCPP_HIDE_FROM_ABI const_reference front() const { return c.front(); } |
| 326 |
_LIBCPP_HIDE_FROM_ABI reference back() { return c.back(); } |
| 327 |
_LIBCPP_HIDE_FROM_ABI const_reference back() const { return c.back(); } |
| 328 |
|
| 329 |
_LIBCPP_HIDE_FROM_ABI void push(const value_type& __v) { c.push_back(__v); } |
| 330 |
_LIBCPP_HIDE_FROM_ABI void pop() { c.pop_front(); } |
| 331 |
|
| 332 |
_LIBCPP_HIDE_FROM_ABI void swap(queue& __q) { |
| 333 |
using std::swap; |
| 334 |
swap(c, __q.c); |
| 335 |
} |
| 336 |
|
| 337 |
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } |
| 338 |
|
| 339 |
template <class _T1, class _OtherContainer> |
| 340 |
friend _LIBCPP_HIDE_FROM_ABI bool |
| 341 |
operator==(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); |
| 342 |
|
| 343 |
template <class _T1, class _OtherContainer> |
| 344 |
friend _LIBCPP_HIDE_FROM_ABI bool |
| 345 |
operator<(const queue<_T1, _OtherContainer>& __x, const queue<_T1, _OtherContainer>& __y); |
| 346 |
}; |
| 347 |
|
| 348 |
template <class _Tp, class _Container> |
| 349 |
inline _LIBCPP_HIDE_FROM_ABI bool operator==(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 350 |
return __x.c == __y.c; |
| 351 |
} |
| 352 |
|
| 353 |
template <class _Tp, class _Container> |
| 354 |
inline _LIBCPP_HIDE_FROM_ABI bool operator<(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 355 |
return __x.c < __y.c; |
| 356 |
} |
| 357 |
|
| 358 |
template <class _Tp, class _Container> |
| 359 |
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 360 |
return !(__x == __y); |
| 361 |
} |
| 362 |
|
| 363 |
template <class _Tp, class _Container> |
| 364 |
inline _LIBCPP_HIDE_FROM_ABI bool operator>(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 365 |
return __y < __x; |
| 366 |
} |
| 367 |
|
| 368 |
template <class _Tp, class _Container> |
| 369 |
inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 370 |
return !(__x < __y); |
| 371 |
} |
| 372 |
|
| 373 |
template <class _Tp, class _Container> |
| 374 |
inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const queue<_Tp, _Container>& __x, const queue<_Tp, _Container>& __y) { |
| 375 |
return !(__y < __x); |
| 376 |
} |
| 377 |
|
| 378 |
template <class _Tp, class _Container, __enable_if_t<__is_swappable_v<_Container>, int> = 0> |
| 379 |
inline _LIBCPP_HIDE_FROM_ABI void swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) { |
| 380 |
__x.swap(__y); |
| 381 |
} |
| 382 |
|
| 383 |
template <class _Tp, class _Container, class _Alloc> |
| 384 |
struct _LIBCPP_TEMPLATE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { |
| 385 |
}; |
| 386 |
|
| 387 |
template <class _Tp, class _Container, class _Compare> |
| 388 |
class _LIBCPP_TEMPLATE_VIS priority_queue { |
| 389 |
public: |
| 390 |
typedef _Container container_type; |
| 391 |
typedef _Compare value_compare; |
| 392 |
typedef typename container_type::value_type value_type; |
| 393 |
typedef typename container_type::reference reference; |
| 394 |
typedef typename container_type::const_reference const_reference; |
| 395 |
typedef typename container_type::size_type size_type; |
| 396 |
static_assert(is_same<_Tp, value_type>::value, ""); |
| 397 |
|
| 398 |
protected: |
| 399 |
container_type c; |
| 400 |
value_compare comp; |
| 401 |
|
| 402 |
public: |
| 403 |
_LIBCPP_HIDE_FROM_ABI priority_queue() : c(), comp() {} |
| 404 |
|
| 405 |
_LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q) : c(__q.c), comp(__q.comp) {} |
| 406 |
|
| 407 |
_LIBCPP_HIDE_FROM_ABI priority_queue& operator=(const priority_queue& __q) { |
| 408 |
c = __q.c; |
| 409 |
comp = __q.comp; |
| 410 |
return *this; |
| 411 |
} |
| 412 |
|
| 413 |
_LIBCPP_HIDE_FROM_ABI explicit priority_queue(const value_compare& __comp) : c(), comp(__comp) {} |
| 414 |
_LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c); |
| 415 |
template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 416 |
_LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp = value_compare()); |
| 417 |
|
| 418 |
template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> = 0> |
| 419 |
_LIBCPP_HIDE_FROM_ABI |
| 420 |
priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c); |
| 421 |
|
| 422 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 423 |
_LIBCPP_HIDE_FROM_ABI explicit priority_queue(const _Alloc& __a); |
| 424 |
|
| 425 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 426 |
_LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const _Alloc& __a); |
| 427 |
|
| 428 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 429 |
_LIBCPP_HIDE_FROM_ABI priority_queue(const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 430 |
|
| 431 |
template <class _Alloc, __enable_if_t<uses_allocator<container_type, _Alloc>::value, int> = 0> |
| 432 |
_LIBCPP_HIDE_FROM_ABI priority_queue(const priority_queue& __q, const _Alloc& __a); |
| 433 |
|
| 434 |
template < |
| 435 |
class _InputIter, |
| 436 |
class _Alloc, |
| 437 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 438 |
int> = 0> |
| 439 |
_LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a); |
| 440 |
|
| 441 |
template < |
| 442 |
class _InputIter, |
| 443 |
class _Alloc, |
| 444 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 445 |
int> = 0> |
| 446 |
_LIBCPP_HIDE_FROM_ABI priority_queue(_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a); |
| 447 |
|
| 448 |
template < |
| 449 |
class _InputIter, |
| 450 |
class _Alloc, |
| 451 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<container_type, _Alloc>::value, |
| 452 |
int> = 0> |
| 453 |
_LIBCPP_HIDE_FROM_ABI priority_queue( |
| 454 |
_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a); |
| 455 |
|
| 456 |
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const { return c.empty(); } |
| 457 |
_LIBCPP_HIDE_FROM_ABI size_type size() const { return c.size(); } |
| 458 |
_LIBCPP_HIDE_FROM_ABI const_reference top() const { return c.front(); } |
| 459 |
|
| 460 |
_LIBCPP_HIDE_FROM_ABI void push(const value_type& __v); |
| 461 |
_LIBCPP_HIDE_FROM_ABI void pop(); |
| 462 |
|
| 463 |
_LIBCPP_HIDE_FROM_ABI void swap(priority_queue& __q); |
| 464 |
|
| 465 |
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI const _Container& __get_container() const { return c; } |
| 466 |
}; |
| 467 |
|
| 468 |
template <class _Tp, class _Container, class _Compare> |
| 469 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Compare& __comp, const container_type& __c) |
| 470 |
: c(__c), comp(__comp) { |
| 471 |
std::make_heap(c.begin(), c.end(), comp); |
| 472 |
} |
| 473 |
|
| 474 |
template <class _Tp, class _Container, class _Compare> |
| 475 |
template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 476 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 477 |
_InputIter __f, _InputIter __l, const value_compare& __comp) |
| 478 |
: c(__f, __l), comp(__comp) { |
| 479 |
std::make_heap(c.begin(), c.end(), comp); |
| 480 |
} |
| 481 |
|
| 482 |
template <class _Tp, class _Container, class _Compare> |
| 483 |
template <class _InputIter, __enable_if_t<__has_input_iterator_category<_InputIter>::value, int> > |
| 484 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 485 |
_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c) |
| 486 |
: c(__c), comp(__comp) { |
| 487 |
c.insert(c.end(), __f, __l); |
| 488 |
std::make_heap(c.begin(), c.end(), comp); |
| 489 |
} |
| 490 |
|
| 491 |
template <class _Tp, class _Container, class _Compare> |
| 492 |
template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 493 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const _Alloc& __a) : c(__a) {} |
| 494 |
|
| 495 |
template <class _Tp, class _Container, class _Compare> |
| 496 |
template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 497 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const value_compare& __comp, const _Alloc& __a) |
| 498 |
: c(__a), comp(__comp) {} |
| 499 |
|
| 500 |
template <class _Tp, class _Container, class _Compare> |
| 501 |
template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 502 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 503 |
const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 504 |
: c(__c, __a), comp(__comp) { |
| 505 |
std::make_heap(c.begin(), c.end(), comp); |
| 506 |
} |
| 507 |
|
| 508 |
template <class _Tp, class _Container, class _Compare> |
| 509 |
template <class _Alloc, __enable_if_t<uses_allocator<_Container, _Alloc>::value, int> > |
| 510 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue(const priority_queue& __q, const _Alloc& __a) |
| 511 |
: c(__q.c, __a), comp(__q.comp) {} |
| 512 |
|
| 513 |
template <class _Tp, class _Container, class _Compare> |
| 514 |
template < |
| 515 |
class _InputIter, |
| 516 |
class _Alloc, |
| 517 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 518 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue(_InputIter __f, _InputIter __l, const _Alloc& __a) |
| 519 |
: c(__f, __l, __a), comp() { |
| 520 |
std::make_heap(c.begin(), c.end(), comp); |
| 521 |
} |
| 522 |
|
| 523 |
template <class _Tp, class _Container, class _Compare> |
| 524 |
template < |
| 525 |
class _InputIter, |
| 526 |
class _Alloc, |
| 527 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 528 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 529 |
_InputIter __f, _InputIter __l, const value_compare& __comp, const _Alloc& __a) |
| 530 |
: c(__f, __l, __a), comp(__comp) { |
| 531 |
std::make_heap(c.begin(), c.end(), comp); |
| 532 |
} |
| 533 |
|
| 534 |
template <class _Tp, class _Container, class _Compare> |
| 535 |
template < |
| 536 |
class _InputIter, |
| 537 |
class _Alloc, |
| 538 |
__enable_if_t<__has_input_iterator_category<_InputIter>::value && uses_allocator<_Container, _Alloc>::value, int> > |
| 539 |
inline priority_queue<_Tp, _Container, _Compare>::priority_queue( |
| 540 |
_InputIter __f, _InputIter __l, const value_compare& __comp, const container_type& __c, const _Alloc& __a) |
| 541 |
: c(__c, __a), comp(__comp) { |
| 542 |
c.insert(c.end(), __f, __l); |
| 543 |
std::make_heap(c.begin(), c.end(), comp); |
| 544 |
} |
| 545 |
|
| 546 |
template <class _Tp, class _Container, class _Compare> |
| 547 |
inline void priority_queue<_Tp, _Container, _Compare>::push(const value_type& __v) { |
| 548 |
c.push_back(__v); |
| 549 |
std::push_heap(c.begin(), c.end(), comp); |
| 550 |
} |
| 551 |
|
| 552 |
template <class _Tp, class _Container, class _Compare> |
| 553 |
inline void priority_queue<_Tp, _Container, _Compare>::pop() { |
| 554 |
std::pop_heap(c.begin(), c.end(), comp); |
| 555 |
c.pop_back(); |
| 556 |
} |
| 557 |
|
| 558 |
template <class _Tp, class _Container, class _Compare> |
| 559 |
inline void priority_queue<_Tp, _Container, _Compare>::swap(priority_queue& __q) { |
| 560 |
using std::swap; |
| 561 |
swap(c, __q.c); |
| 562 |
swap(comp, __q.comp); |
| 563 |
} |
| 564 |
|
| 565 |
template <class _Tp, |
| 566 |
class _Container, |
| 567 |
class _Compare, |
| 568 |
__enable_if_t<__is_swappable_v<_Container> && __is_swappable_v<_Compare>, int> = 0> |
| 569 |
inline _LIBCPP_HIDE_FROM_ABI void |
| 570 |
swap(priority_queue<_Tp, _Container, _Compare>& __x, priority_queue<_Tp, _Container, _Compare>& __y) { |
| 571 |
__x.swap(__y); |
| 572 |
} |
| 573 |
|
| 574 |
template <class _Tp, class _Container, class _Compare, class _Alloc> |
| 575 |
struct _LIBCPP_TEMPLATE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> |
| 576 |
: public uses_allocator<_Container, _Alloc> {}; |
| 577 |
|
| 578 |
_LIBCPP_END_NAMESPACE_STD |
| 579 |
|
| 580 |
_LIBCPP_POP_MACROS |
| 581 |
|
| 582 |
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) |
| 583 |
# include <__cxx03/cstdlib> |
| 584 |
# include <__cxx03/functional> |
| 585 |
# include <__cxx03/type_traits> |
| 586 |
#endif |
| 587 |
|
| 588 |
#endif // _LIBCPP___CXX03_QUEUE |