Created
June 14, 2018 00:31
-
-
Save lb5160482/f813d9d4502f50799b5d078af4cd2c13 to your computer and use it in GitHub Desktop.
C++ priority_queue overload comparison function
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
struct com{ | |
bool operator()( T &t1, T &t2) { | |
if(t1.x != t2.x) { | |
return t1.x < t2.x -->按x降序 | |
} | |
return t1.y > t2.y -->x相等时按y升序 | |
} | |
}; | |
priority_queue<T, vector<T>, com> que; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment