다음을 통해 공유


priority_queue::pop

Removes the largest element of the priority_queue from the top position.

void pop( );

설명

The priority_queue must be nonempty to apply the member function. The top of the priority_queue is always occupied by the largest element in the container.

예제

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

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

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

   priority_queue <int>::size_type i, iii;
   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;

   q1.pop( );

   iii = q1.size( );
   cout << "After a pop, the priority_queue length is " 
        << iii << "." << endl;

   const int& iv = q1.top( );
   cout << "After a pop, the element at the top of the "
        << "priority_queue is " << iv << "." << endl;
}
  

요구 사항

Header: <queue>

네임스페이스: std

참고 항목

참조

priority_queue 클래스

priority_queue 함수

표준 템플릿 라이브러리