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


priority_queue::push

Добавляет элемент в очереди с приоритетами на основе приоритета элемента из operator<.

void push(
   const Type& _Val
);

Параметры

  • _Val
    Элемент, добавляемый в верхней части priority_queue.

Заметки

Верхняя часть priority_queue позиция, занимаемая наибольшим элементом в контейнере.

Пример

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

Требования

заголовок: <queue>

std пространство имен:

См. также

Ссылки

priority_queue Class

priority_queue Functions

Стандартная библиотека шаблонов