Switch to full style
C++ code examples
Post a reply

priority queue

Thu Nov 13, 2008 7:52 pm

Implementing C++ priority queue.
cpp code
#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

*/




Post a reply
  Related Posts  to : priority queue
 Circular Queue     -  
 generic queue     -  
 Queue Header     -  
 CPU priority algorithm...     -  
 queue of objects keep track of the front and rear     -  
 task's priority and how is it used in scheduling?     -  
 cpu priority scheduling in java---codes please..     -  
 source code for SJF and priority for both preemptive C#     -  
 Implementation of FCFS, SJFS, Round Robin and priority algo     -  

Topic Tags

C++ Data Structures