Created
August 20, 2013 18:06
-
-
Save ygabo/6284984 to your computer and use it in GitHub Desktop.
Priority queue with a custom class.
This file contains 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 <string> | |
#include <vector> | |
#include <math.h> | |
#include <map> | |
#include <fstream> | |
#include < ctime > | |
#include <algorithm> | |
#include <numeric> | |
#include <set> | |
#include <queue> | |
using namespace std; | |
class Person{ | |
public: | |
int num; | |
Person():num(0){} | |
Person(int i):num(i){} | |
}; | |
bool operator<(const Person &a, const Person &b){ | |
return a.num > b.num; | |
} | |
int main(){ | |
Person a(1),b(2),c(3),e(4); | |
priority_queue<Person> d; | |
d.push(b); d.push(c); d.push(e); d.push(a); | |
cout << d.size() << endl; | |
queue<Person> s(); | |
while(!d.empty()){ | |
cout << d.top().num << " "; | |
d.pop(); | |
} | |
cout << endl <<"done" <<endl; | |
cin.get(); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment