Skip to content

Instantly share code, notes, and snippets.

@yzchen
Created May 9, 2019 15:43
Show Gist options
  • Save yzchen/b56dba0e8c26896b2f8050c9efc5e1b7 to your computer and use it in GitHub Desktop.
Save yzchen/b56dba0e8c26896b2f8050c9efc5e1b7 to your computer and use it in GitHub Desktop.
compare mechanism of priority_queue of pairs
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef pair<int, int> pi;
// Driver program to test methods of graph class
int main()
{
// By default a min heap is created ordered
// by first element of pair.
priority_queue<pi, vector<pi>, greater<pi> > pq;
pq.push(make_pair(10, 20));
pq.push(make_pair(20, 1));
pq.push(make_pair(15, 4));
pair<int, int> top = pq.top();
cout << top.first << " " << top.second;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment