Created
May 9, 2019 15:43
-
-
Save yzchen/b56dba0e8c26896b2f8050c9efc5e1b7 to your computer and use it in GitHub Desktop.
compare mechanism of priority_queue of pairs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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