/*
优先级队列的使用方法及注意事项
*/
#include <iostream>
#include <queue>
using namespace std;
struct Node{
int a, b;
Node(int aa = 0, int bb = 0){
a = aa, b = bb;
}
friend bool operator < (Node n1, Node n2){
// return True when n1 priority < n2 priority
// i.e. priority top is n2
if(n1.a > n2.a){
//Bigger a, less priority
//i.e. sort from small to big depend on "Node.a"
return true;
}
return false;
}
};
int main(){
priority_queue<Node> pq;
pq.push(Node(1, 1));
pq.push(Node(3, 2));
pq.push(Node(2, 3));
cout << "a\t" << "b" << endl;
while(!pq.empty()){
Node n = pq.top();
pq.pop();
cout << n.a << "\t" << n.b << endl;
}
return 0;
}