Syntax:
#include <queue> const TYPE& top() const;
The function top() returns a reference to the top element of the priority queue. The top element is greater or at least as great as any other element in the priority queue.
For example, the following code removes all of the elements from a priority queue and uses top() to display them. Note that the elements are displayed in descending order, because top() returns the largest element in the queue:
while( !s.empty() ) { cout << s.top() << " "; s.pop(); }
Related Topics: pop