From Jason Turner

[priqueue.overview]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmph2s8pb4s/{from.md → to.md} +83 -0
tmp/tmph2s8pb4s/{from.md → to.md} RENAMED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Overview <a id="priqueue.overview">[[priqueue.overview]]</a>
2
+
3
+ Any sequence container with random access iterator and supporting
4
+ operations `front()`, `push_back()` and `pop_back()` can be used to
5
+ instantiate `priority_queue`. In particular, `vector` [[vector]] and
6
+ `deque` [[deque]] can be used. Instantiating `priority_queue` also
7
+ involves supplying a function or function object for making priority
8
+ comparisons; the library assumes that the function or function object
9
+ defines a strict weak ordering [[alg.sorting]].
10
+
11
+ ``` cpp
12
+ namespace std {
13
+ template<class T, class Container = vector<T>,
14
+ class Compare = less<typename Container::value_type>>
15
+ class priority_queue {
16
+ public:
17
+ using value_type = typename Container::value_type;
18
+ using reference = typename Container::reference;
19
+ using const_reference = typename Container::const_reference;
20
+ using size_type = typename Container::size_type;
21
+ using container_type = Container;
22
+ using value_compare = Compare;
23
+
24
+ protected:
25
+ Container c;
26
+ Compare comp;
27
+
28
+ public:
29
+ priority_queue() : priority_queue(Compare()) {}
30
+ explicit priority_queue(const Compare& x) : priority_queue(x, Container()) {}
31
+ priority_queue(const Compare& x, const Container&);
32
+ priority_queue(const Compare& x, Container&&);
33
+ template<class InputIterator>
34
+ priority_queue(InputIterator first, InputIterator last, const Compare& x,
35
+ const Container&);
36
+ template<class InputIterator>
37
+ priority_queue(InputIterator first, InputIterator last,
38
+ const Compare& x = Compare(), Container&& = Container());
39
+ template<class Alloc> explicit priority_queue(const Alloc&);
40
+ template<class Alloc> priority_queue(const Compare&, const Alloc&);
41
+ template<class Alloc> priority_queue(const Compare&, const Container&, const Alloc&);
42
+ template<class Alloc> priority_queue(const Compare&, Container&&, const Alloc&);
43
+ template<class Alloc> priority_queue(const priority_queue&, const Alloc&);
44
+ template<class Alloc> priority_queue(priority_queue&&, const Alloc&);
45
+
46
+ [[nodiscard]] bool empty() const { return c.empty(); }
47
+ size_type size() const { return c.size(); }
48
+ const_reference top() const { return c.front(); }
49
+ void push(const value_type& x);
50
+ void push(value_type&& x);
51
+ template<class... Args> void emplace(Args&&... args);
52
+ void pop();
53
+ void swap(priority_queue& q) noexcept(is_nothrow_swappable_v<Container> &&
54
+ is_nothrow_swappable_v<Compare>)
55
+ { using std::swap; swap(c, q.c); swap(comp, q.comp); }
56
+ };
57
+
58
+ template<class Compare, class Container>
59
+ priority_queue(Compare, Container)
60
+ -> priority_queue<typename Container::value_type, Container, Compare>;
61
+
62
+ template<class InputIterator,
63
+ class Compare = less<typename iterator_traits<InputIterator>::value_type>,
64
+ class Container = vector<typename iterator_traits<InputIterator>::value_type>>
65
+ priority_queue(InputIterator, InputIterator, Compare = Compare(), Container = Container())
66
+ -> priority_queue<typename iterator_traits<InputIterator>::value_type, Container, Compare>;
67
+
68
+ template<class Compare, class Container, class Allocator>
69
+ priority_queue(Compare, Container, Allocator)
70
+ -> priority_queue<typename Container::value_type, Container, Compare>;
71
+
72
+ // no equality is provided
73
+
74
+ template<class T, class Container, class Compare>
75
+ void swap(priority_queue<T, Container, Compare>& x,
76
+ priority_queue<T, Container, Compare>& y) noexcept(noexcept(x.swap(y)));
77
+
78
+ template<class T, class Container, class Compare, class Alloc>
79
+ struct uses_allocator<priority_queue<T, Container, Compare>, Alloc>
80
+ : uses_allocator<Container, Alloc>::type { };
81
+ }
82
+ ```
83
+