Поделиться через


priority_queue::push

Adds an element to the priority queue based on the priority of the element from operator<.

void push( 
   const Type& _Val 
);

Parameters

  • _Val
    The element added to the top of the priority_queue.

Remarks

The top of the priority_queue is the position occupied by the largest element in the container.

Example

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

int main( )
{
   using namespace std;
   priority_queue<int> q1;

   q1.push( 10 );
   q1.push( 30 );
   q1.push( 20 );

   priority_queue<int>::size_type i;
   i = q1.size( );
   cout << "The priority_queue length is " << i << "." << endl;

   const int& ii = q1.top( );
   cout << "The element at the top of the priority_queue is "
        << ii << "." << endl;
}
The priority_queue length is 3.
The element at the top of the priority_queue is 30.

Requirements

Header: <queue>

Namespace: std

See Also

Reference

priority_queue Class

priority_queue Functions

Standard Template Library