Firstly, I find that priority_queue<int>
will give higher priority to bigger integer.
While if we use priority_queue<int, vector<int>, greater>
then it do it in an inverse. Why?
Also, it seems that the comparator we put in the priority queue is not a function pointer. Instead it was defined as:
struct cmp{
bool operator() (const int& lhs, const int&rhs) const
{
...
}
}
I heard this is a very useful property of C++; could anyone explains this type of code to me?