#include <iostream>
#include <string>
#include <queue>
using namespace std;
class Prioritize {
public:
int operator() ( const pair<string, unsigned int>& p1,
const pair<string, unsigned int>& p2 ) {
return p1.second < p2.second;
}
};
int main()
{
priority_queue< pair< string, unsigned int >,
vector <pair< string, unsigned int > >, Prioritize > pq;
pq.push( pair<string, int>( "Event 1", 2) );
pq.push( pair<string, int>( "Event 2", 10 ) );
pq.push( pair<string, int>( "Event 3", 1 ) );
while ( !pq. empty() ) {
cout << pq.top().first << endl;
pq.pop();
}
return 0;
}
|