tmp/tmps46inp_j/{from.md → to.md}
RENAMED
|
@@ -14,67 +14,70 @@ defines a strict weak ordering [[alg.sorting]].
|
|
| 14 |
namespace std {
|
| 15 |
template<class T, class Container = vector<T>,
|
| 16 |
class Compare = less<typename Container::value_type>>
|
| 17 |
class priority_queue {
|
| 18 |
public:
|
| 19 |
-
using value_type =
|
| 20 |
-
using reference =
|
| 21 |
-
using const_reference =
|
| 22 |
-
using size_type =
|
| 23 |
using container_type = Container;
|
| 24 |
using value_compare = Compare;
|
| 25 |
|
| 26 |
protected:
|
| 27 |
Container c;
|
| 28 |
Compare comp;
|
| 29 |
|
| 30 |
public:
|
| 31 |
-
priority_queue() : priority_queue(Compare()) {}
|
| 32 |
-
explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
|
| 33 |
-
priority_queue(const Compare& x, const Container&);
|
| 34 |
-
priority_queue(const Compare& x, Container&&);
|
| 35 |
template<class InputIterator>
|
| 36 |
-
priority_queue(InputIterator first, InputIterator last,
|
|
|
|
| 37 |
template<class InputIterator>
|
| 38 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 39 |
const Container&);
|
| 40 |
template<class InputIterator>
|
| 41 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 42 |
Container&&);
|
| 43 |
template<container-compatible-range<T> R>
|
| 44 |
-
priority_queue(from_range_t, R&& rg, const Compare& x = Compare());
|
| 45 |
-
template<class Alloc> explicit priority_queue(const Alloc&);
|
| 46 |
-
template<class Alloc> priority_queue(const Compare&, const Alloc&);
|
| 47 |
-
template<class Alloc>
|
| 48 |
-
|
| 49 |
-
template<class Alloc> priority_queue(const
|
| 50 |
-
template<class Alloc> priority_queue(priority_queue&
|
|
|
|
| 51 |
template<class InputIterator, class Alloc>
|
| 52 |
-
priority_queue(InputIterator, InputIterator, const Alloc&);
|
| 53 |
template<class InputIterator, class Alloc>
|
| 54 |
-
priority_queue(InputIterator, InputIterator, const Compare&, const Alloc&);
|
| 55 |
template<class InputIterator, class Alloc>
|
| 56 |
-
priority_queue(InputIterator, InputIterator, const Compare&, const Container&,
|
| 57 |
const Alloc&);
|
| 58 |
template<class InputIterator, class Alloc>
|
| 59 |
-
priority_queue(InputIterator, InputIterator, const Compare&, Container&&,
|
|
|
|
| 60 |
template<container-compatible-range<T> R, class Alloc>
|
| 61 |
-
priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&);
|
| 62 |
template<container-compatible-range<T> R, class Alloc>
|
| 63 |
-
priority_queue(from_range_t, R&& rg, const Alloc&);
|
| 64 |
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
const_reference
|
| 68 |
-
void push(const value_type& x);
|
| 69 |
-
void push(value_type&& x);
|
| 70 |
template<container-compatible-range<T> R>
|
| 71 |
-
void push_range(R&& rg);
|
| 72 |
-
template<class... Args> void emplace(Args&&... args);
|
| 73 |
-
void pop();
|
| 74 |
-
void swap(priority_queue& q)
|
| 75 |
-
|
| 76 |
{ using std::swap; swap(c, q.c); swap(comp, q.comp); }
|
| 77 |
};
|
| 78 |
|
| 79 |
template<class Compare, class Container>
|
| 80 |
priority_queue(Compare, Container)
|
|
@@ -127,36 +130,38 @@ namespace std {
|
|
| 127 |
```
|
| 128 |
|
| 129 |
#### Constructors <a id="priqueue.cons">[[priqueue.cons]]</a>
|
| 130 |
|
| 131 |
``` cpp
|
| 132 |
-
priority_queue(const Compare& x, const Container& y);
|
| 133 |
-
priority_queue(const Compare& x, Container&& y);
|
| 134 |
```
|
| 135 |
|
| 136 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 137 |
|
| 138 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 139 |
constructing or move constructing as appropriate); calls
|
| 140 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 141 |
|
| 142 |
``` cpp
|
| 143 |
template<class InputIterator>
|
| 144 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
|
| 145 |
```
|
| 146 |
|
| 147 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 148 |
|
| 149 |
*Effects:* Initializes `c` with `first` as the first argument and `last`
|
| 150 |
as the second argument, and initializes `comp` with `x`; then calls
|
| 151 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 152 |
|
| 153 |
``` cpp
|
| 154 |
template<class InputIterator>
|
| 155 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
|
|
|
| 156 |
template<class InputIterator>
|
| 157 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
|
|
|
| 158 |
```
|
| 159 |
|
| 160 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 161 |
|
| 162 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
|
@@ -164,11 +169,11 @@ constructing or move constructing as appropriate); calls
|
|
| 164 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 165 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 166 |
|
| 167 |
``` cpp
|
| 168 |
template<container-compatible-range<T> R>
|
| 169 |
-
priority_queue(from_range_t, R&& rg, const Compare& x = Compare());
|
| 170 |
```
|
| 171 |
|
| 172 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 173 |
|
| 174 |
*Effects:* Initializes `comp` with `x` and `c` with
|
|
@@ -179,128 +184,129 @@ template<container-compatible-range<T> R>
|
|
| 179 |
|
| 180 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 181 |
in this subclause shall not participate in overload resolution.
|
| 182 |
|
| 183 |
``` cpp
|
| 184 |
-
template<class Alloc> explicit priority_queue(const Alloc& a);
|
| 185 |
```
|
| 186 |
|
| 187 |
*Effects:* Initializes `c` with `a` and value-initializes `comp`.
|
| 188 |
|
| 189 |
``` cpp
|
| 190 |
-
template<class Alloc> priority_queue(const Compare& compare, const Alloc& a);
|
| 191 |
```
|
| 192 |
|
| 193 |
*Effects:* Initializes `c` with `a` and initializes `comp` with
|
| 194 |
`compare`.
|
| 195 |
|
| 196 |
``` cpp
|
| 197 |
template<class Alloc>
|
| 198 |
-
priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
|
| 199 |
```
|
| 200 |
|
| 201 |
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 202 |
the second argument, and initializes `comp` with `compare`; calls
|
| 203 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 204 |
|
| 205 |
``` cpp
|
| 206 |
template<class Alloc>
|
| 207 |
-
priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
|
| 208 |
```
|
| 209 |
|
| 210 |
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 211 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 212 |
calls `make_heap(c.begin(), c.end(), comp)`.
|
| 213 |
|
| 214 |
``` cpp
|
| 215 |
-
template<class Alloc> priority_queue(const priority_queue& q, const Alloc& a);
|
| 216 |
```
|
| 217 |
|
| 218 |
*Effects:* Initializes `c` with `q.c` as the first argument and `a` as
|
| 219 |
the second argument, and initializes `comp` with `q.comp`.
|
| 220 |
|
| 221 |
``` cpp
|
| 222 |
-
template<class Alloc> priority_queue(priority_queue&& q, const Alloc& a);
|
| 223 |
```
|
| 224 |
|
| 225 |
*Effects:* Initializes `c` with `std::move(q.c)` as the first argument
|
| 226 |
and `a` as the second argument, and initializes `comp` with
|
| 227 |
`std::move(q.comp)`.
|
| 228 |
|
| 229 |
``` cpp
|
| 230 |
template<class InputIterator, class Alloc>
|
| 231 |
-
priority_queue(InputIterator first, InputIterator last, const Alloc& a);
|
| 232 |
```
|
| 233 |
|
| 234 |
*Effects:* Initializes `c` with `first` as the first argument, `last` as
|
| 235 |
the second argument, and `a` as the third argument, and
|
| 236 |
value-initializes `comp`; calls `make_heap(c.begin(), c.end(), comp)`.
|
| 237 |
|
| 238 |
``` cpp
|
| 239 |
template<class InputIterator, class Alloc>
|
| 240 |
-
priority_queue(InputIterator first, InputIterator last,
|
|
|
|
| 241 |
```
|
| 242 |
|
| 243 |
*Effects:* Initializes `c` with `first` as the first argument, `last` as
|
| 244 |
the second argument, and `a` as the third argument, and initializes
|
| 245 |
`comp` with `compare`; calls `make_heap(c.begin(), c.end(), comp)`.
|
| 246 |
|
| 247 |
``` cpp
|
| 248 |
template<class InputIterator, class Alloc>
|
| 249 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& compare,
|
| 250 |
const Container& cont, const Alloc& a);
|
| 251 |
```
|
| 252 |
|
| 253 |
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 254 |
the second argument, and initializes `comp` with `compare`; calls
|
| 255 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 256 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 257 |
|
| 258 |
``` cpp
|
| 259 |
template<class InputIterator, class Alloc>
|
| 260 |
-
priority_queue(InputIterator first, InputIterator last, const Compare& compare,
|
| 261 |
-
|
| 262 |
```
|
| 263 |
|
| 264 |
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 265 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 266 |
calls `c.insert(c.end(), first, last)`; and finally calls
|
| 267 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 268 |
|
| 269 |
``` cpp
|
| 270 |
template<container-compatible-range<T> R, class Alloc>
|
| 271 |
-
priority_queue(from_range_t, R&& rg, const Compare& compare, const Alloc& a);
|
| 272 |
```
|
| 273 |
|
| 274 |
*Effects:* Initializes `comp` with `compare` and `c` with
|
| 275 |
`ranges::to<Container>(std::forward<R>(rg), a)`; calls
|
| 276 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 277 |
|
| 278 |
``` cpp
|
| 279 |
template<container-compatible-range<T> R, class Alloc>
|
| 280 |
-
priority_queue(from_range_t, R&& rg, const Alloc& a);
|
| 281 |
```
|
| 282 |
|
| 283 |
*Effects:* Initializes `c` with
|
| 284 |
-
`ranges::to<Container>(std::forward<R>(rg), a)`
|
| 285 |
-
`make_heap(c.begin(), c.end(), comp)`.
|
| 286 |
|
| 287 |
#### Members <a id="priqueue.members">[[priqueue.members]]</a>
|
| 288 |
|
| 289 |
``` cpp
|
| 290 |
-
void push(const value_type& x);
|
| 291 |
```
|
| 292 |
|
| 293 |
*Effects:* As if by:
|
| 294 |
|
| 295 |
``` cpp
|
| 296 |
c.push_back(x);
|
| 297 |
push_heap(c.begin(), c.end(), comp);
|
| 298 |
```
|
| 299 |
|
| 300 |
``` cpp
|
| 301 |
-
void push(value_type&& x);
|
| 302 |
```
|
| 303 |
|
| 304 |
*Effects:* As if by:
|
| 305 |
|
| 306 |
``` cpp
|
|
@@ -308,33 +314,33 @@ c.push_back(std::move(x));
|
|
| 308 |
push_heap(c.begin(), c.end(), comp);
|
| 309 |
```
|
| 310 |
|
| 311 |
``` cpp
|
| 312 |
template<container-compatible-range<T> R>
|
| 313 |
-
void push_range(R&& rg);
|
| 314 |
```
|
| 315 |
|
| 316 |
*Effects:* Inserts all elements of `rg` in `c` via
|
| 317 |
`c.append_range(std::forward<R>(rg))` if that is a valid expression, or
|
| 318 |
`ranges::copy(rg, back_inserter(c))` otherwise. Then restores the heap
|
| 319 |
property as if by `make_heap(c.begin(), c.end(), comp)`.
|
| 320 |
|
| 321 |
*Ensures:* `is_heap(c.begin(), c.end(), comp)` is `true`.
|
| 322 |
|
| 323 |
``` cpp
|
| 324 |
-
template<class... Args> void emplace(Args&&... args);
|
| 325 |
```
|
| 326 |
|
| 327 |
*Effects:* As if by:
|
| 328 |
|
| 329 |
``` cpp
|
| 330 |
c.emplace_back(std::forward<Args>(args)...);
|
| 331 |
push_heap(c.begin(), c.end(), comp);
|
| 332 |
```
|
| 333 |
|
| 334 |
``` cpp
|
| 335 |
-
void pop();
|
| 336 |
```
|
| 337 |
|
| 338 |
*Effects:* As if by:
|
| 339 |
|
| 340 |
``` cpp
|
|
@@ -344,11 +350,11 @@ c.pop_back();
|
|
| 344 |
|
| 345 |
#### Specialized algorithms <a id="priqueue.special">[[priqueue.special]]</a>
|
| 346 |
|
| 347 |
``` cpp
|
| 348 |
template<class T, class Container, class Compare>
|
| 349 |
-
void swap(priority_queue<T, Container, Compare>& x,
|
| 350 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
| 351 |
```
|
| 352 |
|
| 353 |
*Constraints:* `is_swappable_v<Container>` is `true` and
|
| 354 |
`is_swappable_v<Compare>` is `true`.
|
|
|
|
| 14 |
namespace std {
|
| 15 |
template<class T, class Container = vector<T>,
|
| 16 |
class Compare = less<typename Container::value_type>>
|
| 17 |
class priority_queue {
|
| 18 |
public:
|
| 19 |
+
using value_type = Container::value_type;
|
| 20 |
+
using reference = Container::reference;
|
| 21 |
+
using const_reference = Container::const_reference;
|
| 22 |
+
using size_type = Container::size_type;
|
| 23 |
using container_type = Container;
|
| 24 |
using value_compare = Compare;
|
| 25 |
|
| 26 |
protected:
|
| 27 |
Container c;
|
| 28 |
Compare comp;
|
| 29 |
|
| 30 |
public:
|
| 31 |
+
constexpr priority_queue() : priority_queue(Compare()) {}
|
| 32 |
+
constexpr explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
|
| 33 |
+
constexpr priority_queue(const Compare& x, const Container&);
|
| 34 |
+
constexpr priority_queue(const Compare& x, Container&&);
|
| 35 |
template<class InputIterator>
|
| 36 |
+
constexpr priority_queue(InputIterator first, InputIterator last,
|
| 37 |
+
const Compare& x = Compare());
|
| 38 |
template<class InputIterator>
|
| 39 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 40 |
const Container&);
|
| 41 |
template<class InputIterator>
|
| 42 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 43 |
Container&&);
|
| 44 |
template<container-compatible-range<T> R>
|
| 45 |
+
constexpr priority_queue(from_range_t, R&& rg, const Compare& x = Compare());
|
| 46 |
+
template<class Alloc> constexpr explicit priority_queue(const Alloc&);
|
| 47 |
+
template<class Alloc> constexpr priority_queue(const Compare&, const Alloc&);
|
| 48 |
+
template<class Alloc>
|
| 49 |
+
constexpr priority_queue(const Compare&, const Container&, const Alloc&);
|
| 50 |
+
template<class Alloc> constexpr priority_queue(const Compare&, Container&&, const Alloc&);
|
| 51 |
+
template<class Alloc> constexpr priority_queue(const priority_queue&, const Alloc&);
|
| 52 |
+
template<class Alloc> constexpr priority_queue(priority_queue&&, const Alloc&);
|
| 53 |
template<class InputIterator, class Alloc>
|
| 54 |
+
constexpr priority_queue(InputIterator, InputIterator, const Alloc&);
|
| 55 |
template<class InputIterator, class Alloc>
|
| 56 |
+
constexpr priority_queue(InputIterator, InputIterator, const Compare&, const Alloc&);
|
| 57 |
template<class InputIterator, class Alloc>
|
| 58 |
+
constexpr priority_queue(InputIterator, InputIterator, const Compare&, const Container&,
|
| 59 |
const Alloc&);
|
| 60 |
template<class InputIterator, class Alloc>
|
| 61 |
+
constexpr priority_queue(InputIterator, InputIterator, const Compare&, Container&&,
|
| 62 |
+
const Alloc&);
|
| 63 |
template<container-compatible-range<T> R, class Alloc>
|
| 64 |
+
constexpr priority_queue(from_range_t, R&& rg, const Compare&, const Alloc&);
|
| 65 |
template<container-compatible-range<T> R, class Alloc>
|
| 66 |
+
constexpr priority_queue(from_range_t, R&& rg, const Alloc&);
|
| 67 |
|
| 68 |
+
constexpr bool empty() const { return c.empty(); }
|
| 69 |
+
constexpr size_type size() const { return c.size(); }
|
| 70 |
+
constexpr const_reference top() const { return c.front(); }
|
| 71 |
+
constexpr void push(const value_type& x);
|
| 72 |
+
constexpr void push(value_type&& x);
|
| 73 |
template<container-compatible-range<T> R>
|
| 74 |
+
constexpr void push_range(R&& rg);
|
| 75 |
+
template<class... Args> constexpr void emplace(Args&&... args);
|
| 76 |
+
constexpr void pop();
|
| 77 |
+
constexpr void swap(priority_queue& q)
|
| 78 |
+
noexcept(is_nothrow_swappable_v<Container> && is_nothrow_swappable_v<Compare>)
|
| 79 |
{ using std::swap; swap(c, q.c); swap(comp, q.comp); }
|
| 80 |
};
|
| 81 |
|
| 82 |
template<class Compare, class Container>
|
| 83 |
priority_queue(Compare, Container)
|
|
|
|
| 130 |
```
|
| 131 |
|
| 132 |
#### Constructors <a id="priqueue.cons">[[priqueue.cons]]</a>
|
| 133 |
|
| 134 |
``` cpp
|
| 135 |
+
constexpr priority_queue(const Compare& x, const Container& y);
|
| 136 |
+
constexpr priority_queue(const Compare& x, Container&& y);
|
| 137 |
```
|
| 138 |
|
| 139 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 140 |
|
| 141 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
| 142 |
constructing or move constructing as appropriate); calls
|
| 143 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 144 |
|
| 145 |
``` cpp
|
| 146 |
template<class InputIterator>
|
| 147 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x = Compare());
|
| 148 |
```
|
| 149 |
|
| 150 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 151 |
|
| 152 |
*Effects:* Initializes `c` with `first` as the first argument and `last`
|
| 153 |
as the second argument, and initializes `comp` with `x`; then calls
|
| 154 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 155 |
|
| 156 |
``` cpp
|
| 157 |
template<class InputIterator>
|
| 158 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 159 |
+
const Container& y);
|
| 160 |
template<class InputIterator>
|
| 161 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& x,
|
| 162 |
+
Container&& y);
|
| 163 |
```
|
| 164 |
|
| 165 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 166 |
|
| 167 |
*Effects:* Initializes `comp` with `x` and `c` with `y` (copy
|
|
|
|
| 169 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 170 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 171 |
|
| 172 |
``` cpp
|
| 173 |
template<container-compatible-range<T> R>
|
| 174 |
+
constexpr priority_queue(from_range_t, R&& rg, const Compare& x = Compare());
|
| 175 |
```
|
| 176 |
|
| 177 |
*Preconditions:* `x` defines a strict weak ordering [[alg.sorting]].
|
| 178 |
|
| 179 |
*Effects:* Initializes `comp` with `x` and `c` with
|
|
|
|
| 184 |
|
| 185 |
If `uses_allocator_v<container_type, Alloc>` is `false` the constructors
|
| 186 |
in this subclause shall not participate in overload resolution.
|
| 187 |
|
| 188 |
``` cpp
|
| 189 |
+
template<class Alloc> constexpr explicit priority_queue(const Alloc& a);
|
| 190 |
```
|
| 191 |
|
| 192 |
*Effects:* Initializes `c` with `a` and value-initializes `comp`.
|
| 193 |
|
| 194 |
``` cpp
|
| 195 |
+
template<class Alloc> constexpr priority_queue(const Compare& compare, const Alloc& a);
|
| 196 |
```
|
| 197 |
|
| 198 |
*Effects:* Initializes `c` with `a` and initializes `comp` with
|
| 199 |
`compare`.
|
| 200 |
|
| 201 |
``` cpp
|
| 202 |
template<class Alloc>
|
| 203 |
+
constexpr priority_queue(const Compare& compare, const Container& cont, const Alloc& a);
|
| 204 |
```
|
| 205 |
|
| 206 |
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 207 |
the second argument, and initializes `comp` with `compare`; calls
|
| 208 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 209 |
|
| 210 |
``` cpp
|
| 211 |
template<class Alloc>
|
| 212 |
+
constexpr priority_queue(const Compare& compare, Container&& cont, const Alloc& a);
|
| 213 |
```
|
| 214 |
|
| 215 |
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 216 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 217 |
calls `make_heap(c.begin(), c.end(), comp)`.
|
| 218 |
|
| 219 |
``` cpp
|
| 220 |
+
template<class Alloc> constexpr priority_queue(const priority_queue& q, const Alloc& a);
|
| 221 |
```
|
| 222 |
|
| 223 |
*Effects:* Initializes `c` with `q.c` as the first argument and `a` as
|
| 224 |
the second argument, and initializes `comp` with `q.comp`.
|
| 225 |
|
| 226 |
``` cpp
|
| 227 |
+
template<class Alloc> constexpr priority_queue(priority_queue&& q, const Alloc& a);
|
| 228 |
```
|
| 229 |
|
| 230 |
*Effects:* Initializes `c` with `std::move(q.c)` as the first argument
|
| 231 |
and `a` as the second argument, and initializes `comp` with
|
| 232 |
`std::move(q.comp)`.
|
| 233 |
|
| 234 |
``` cpp
|
| 235 |
template<class InputIterator, class Alloc>
|
| 236 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Alloc& a);
|
| 237 |
```
|
| 238 |
|
| 239 |
*Effects:* Initializes `c` with `first` as the first argument, `last` as
|
| 240 |
the second argument, and `a` as the third argument, and
|
| 241 |
value-initializes `comp`; calls `make_heap(c.begin(), c.end(), comp)`.
|
| 242 |
|
| 243 |
``` cpp
|
| 244 |
template<class InputIterator, class Alloc>
|
| 245 |
+
constexpr priority_queue(InputIterator first, InputIterator last,
|
| 246 |
+
const Compare& compare, const Alloc& a);
|
| 247 |
```
|
| 248 |
|
| 249 |
*Effects:* Initializes `c` with `first` as the first argument, `last` as
|
| 250 |
the second argument, and `a` as the third argument, and initializes
|
| 251 |
`comp` with `compare`; calls `make_heap(c.begin(), c.end(), comp)`.
|
| 252 |
|
| 253 |
``` cpp
|
| 254 |
template<class InputIterator, class Alloc>
|
| 255 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& compare,
|
| 256 |
const Container& cont, const Alloc& a);
|
| 257 |
```
|
| 258 |
|
| 259 |
*Effects:* Initializes `c` with `cont` as the first argument and `a` as
|
| 260 |
the second argument, and initializes `comp` with `compare`; calls
|
| 261 |
`c.insert(c.end(), first, last)`; and finally calls
|
| 262 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 263 |
|
| 264 |
``` cpp
|
| 265 |
template<class InputIterator, class Alloc>
|
| 266 |
+
constexpr priority_queue(InputIterator first, InputIterator last, const Compare& compare,
|
| 267 |
+
Container&& cont, const Alloc& a);
|
| 268 |
```
|
| 269 |
|
| 270 |
*Effects:* Initializes `c` with `std::move(cont)` as the first argument
|
| 271 |
and `a` as the second argument, and initializes `comp` with `compare`;
|
| 272 |
calls `c.insert(c.end(), first, last)`; and finally calls
|
| 273 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 274 |
|
| 275 |
``` cpp
|
| 276 |
template<container-compatible-range<T> R, class Alloc>
|
| 277 |
+
constexpr priority_queue(from_range_t, R&& rg, const Compare& compare, const Alloc& a);
|
| 278 |
```
|
| 279 |
|
| 280 |
*Effects:* Initializes `comp` with `compare` and `c` with
|
| 281 |
`ranges::to<Container>(std::forward<R>(rg), a)`; calls
|
| 282 |
`make_heap(c.begin(), c.end(), comp)`.
|
| 283 |
|
| 284 |
``` cpp
|
| 285 |
template<container-compatible-range<T> R, class Alloc>
|
| 286 |
+
constexpr priority_queue(from_range_t, R&& rg, const Alloc& a);
|
| 287 |
```
|
| 288 |
|
| 289 |
*Effects:* Initializes `c` with
|
| 290 |
+
`ranges::to<Container>(std::forward<R>(rg), a)` and value-initializes
|
| 291 |
+
`comp`; calls `make_heap(c.begin(), c.end(), comp)`.
|
| 292 |
|
| 293 |
#### Members <a id="priqueue.members">[[priqueue.members]]</a>
|
| 294 |
|
| 295 |
``` cpp
|
| 296 |
+
constexpr void push(const value_type& x);
|
| 297 |
```
|
| 298 |
|
| 299 |
*Effects:* As if by:
|
| 300 |
|
| 301 |
``` cpp
|
| 302 |
c.push_back(x);
|
| 303 |
push_heap(c.begin(), c.end(), comp);
|
| 304 |
```
|
| 305 |
|
| 306 |
``` cpp
|
| 307 |
+
constexpr void push(value_type&& x);
|
| 308 |
```
|
| 309 |
|
| 310 |
*Effects:* As if by:
|
| 311 |
|
| 312 |
``` cpp
|
|
|
|
| 314 |
push_heap(c.begin(), c.end(), comp);
|
| 315 |
```
|
| 316 |
|
| 317 |
``` cpp
|
| 318 |
template<container-compatible-range<T> R>
|
| 319 |
+
constexpr void push_range(R&& rg);
|
| 320 |
```
|
| 321 |
|
| 322 |
*Effects:* Inserts all elements of `rg` in `c` via
|
| 323 |
`c.append_range(std::forward<R>(rg))` if that is a valid expression, or
|
| 324 |
`ranges::copy(rg, back_inserter(c))` otherwise. Then restores the heap
|
| 325 |
property as if by `make_heap(c.begin(), c.end(), comp)`.
|
| 326 |
|
| 327 |
*Ensures:* `is_heap(c.begin(), c.end(), comp)` is `true`.
|
| 328 |
|
| 329 |
``` cpp
|
| 330 |
+
template<class... Args> constexpr void emplace(Args&&... args);
|
| 331 |
```
|
| 332 |
|
| 333 |
*Effects:* As if by:
|
| 334 |
|
| 335 |
``` cpp
|
| 336 |
c.emplace_back(std::forward<Args>(args)...);
|
| 337 |
push_heap(c.begin(), c.end(), comp);
|
| 338 |
```
|
| 339 |
|
| 340 |
``` cpp
|
| 341 |
+
constexpr void pop();
|
| 342 |
```
|
| 343 |
|
| 344 |
*Effects:* As if by:
|
| 345 |
|
| 346 |
``` cpp
|
|
|
|
| 350 |
|
| 351 |
#### Specialized algorithms <a id="priqueue.special">[[priqueue.special]]</a>
|
| 352 |
|
| 353 |
``` cpp
|
| 354 |
template<class T, class Container, class Compare>
|
| 355 |
+
constexpr void swap(priority_queue<T, Container, Compare>& x,
|
| 356 |
priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
|
| 357 |
```
|
| 358 |
|
| 359 |
*Constraints:* `is_swappable_v<Container>` is `true` and
|
| 360 |
`is_swappable_v<Compare>` is `true`.
|