![[Dept of Engineering]](http://www.eng.cam.ac.uk/images/house_style/engban-s.gif)
Variations include
// create a message structure
struct Message{ ... }
// wait until an item appears on the queue, then process it.
void server(queue<Message> &q)
{
while(!q.empty()) {
Message& m = q.front();
m.service();q.pop();
}
}
[fontsize=\small,frame=single,formatcom=\color{progcolor}]
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
int main()
{
// Make a priority queue of int using a vector container
priority_queue<int, vector<int>, less<int> > pq;
// Push a couple of values
pq.push(1);
pq.push(7);
pq.push(2);
pq.push(2);
pq.push(3);
// Pop all the values off
while(!pq.empty()) {
cout << pq.top() << endl;
pq.pop();
}
return 0;
}