Export (0) Print
Expand All

priority_queue::size

Returns the number of elements in the priority_queue.

size_type size( ) const;

The current length of the priority_queue.

// pqueue_size.cpp
// compile with: /EHsc
#include <queue>
#include <iostream>

int main( )
{
   using namespace std;
   priority_queue <int> q1, q2;
   priority_queue <int>::size_type i;

   q1.push( 1 );
   i = q1.size( );
   cout << "The priority_queue length is " << i << "." << endl;

   q1.push( 2 );
   i = q1.size( );
   cout << "The priority_queue length is now " << i << "." << endl;
}
The priority_queue length is 1.
The priority_queue length is now 2.

Header: <queue>

Namespace: std

Show:
© 2014 Microsoft