priority_queue of double : priority_queue « Queue Stack « C++






priority_queue of double

   
 

#include <iostream>
using std::cout;
using std::endl;

#include <queue>

int main()
{
   std::priority_queue< double > priorities;
   
   priorities.push( 3.2 );
   priorities.push( 9.8 );
   priorities.push( 5.4 );

   cout << "Popping from priorities: ";
   
   while ( !priorities.empty() ) 
   {
      cout << priorities.top() << ' ';
      priorities.pop();
   }

   cout << endl;
   return 0;
}

 /* 
Popping from priorities: 9.8 5.4 3.2

 */       
    
    
  








Related examples in the same category

1.priority_queue: push, pop, top, empty
2.priority_queue: push and size
3.priority_queue: pop
4.priority_queue: top
5.Priority Queue Opertions: empty(), pop(), top(), push()
6.Define your function to Prioritize a priority_queue
7.Using a Priority Queue
8.A priority_queue: size(), top(), empty(), pop()