priority_queue::empty
Tests if a priority_queue is empty.
bool empty( ) const;
Return Value
true if the priority_queue is empty; false if the priority_queue is nonempty.
Example
// pqueue_empty.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>
int main( )
{
using namespace std;
// Declares priority_queues with default deque base container
priority_queue <int> q1, s2;
q1.push( 1 );
if ( q1.empty( ) )
cout << "The priority_queue q1 is empty." << endl;
else
cout << "The priority_queue q1 is not empty." << endl;
if ( s2.empty( ) )
cout << "The priority_queue s2 is empty." << endl;
else
cout << "The priority_queue s2 is not empty." << endl;
}
The priority_queue q1 is not empty. The priority_queue s2 is empty.
Requirements
Header: <queue>
Namespace: std