public member function
<queue>
std::priority_queue::topconst value_type& top() const;
const_reference top() const;
Access top element
Returns a constant reference to the top element in the priority_queue.The top element is the element that compares higher in the priority_queue, and the next that is removed from the container when priority_queue::pop is called.
This member function effectively calls member front of the underlying container object.
Member type value_type is the type of the elements in the container (defined as an alias of the first class template parameter, T).
Member type const_reference is an alias of the underlying container's type with the same name.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// priority_queue::top
#include <iostream> // std::cout
#include <queue> // std::priority_queue
int main ()
{
std::priority_queue<int> mypq;
mypq.push(10);
mypq.push(20);
mypq.push(15);
std::cout << "mypq.top() is now " << mypq.top() << '\n';
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4