Freigeben über


priority_queue::push

Fügt ein Element der Prioritätswarteschlange anhand die Priorität des Elements vom Operator <hinzu.

void push( 
   const Type& _Val 
);

Parameter

  • _Val
    Das Element hinzugefügt Rand des priority_queue.

Hinweise

Oben im priority_queue ist die Position, die das größte Element im Container eingenommen wird.

Beispiel

// 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;
}
  

Anforderungen

Header: <Warteschlange>

Namespace: std

Siehe auch

Referenz

priority_queue-Klasse

priority_queue-Funktionen

Standardvorlagenbibliothek