1.定義比較函數,以函數對象形式
這種方式使用時,需要把函數加入priority_queue的聲明中去
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;
2.在結構體中重載<操作符(重載爲友元函數)
class T{
public:
friend bool operator<(const T &t);
};
priority<T, vector<T> ...