您的位置:首页 > 其它

优先队列-结构体重载

2017-07-26 07:02 155 查看
结构体重载:

重载一:

struct node
{
int value;
friend bool operator < (node a,node b)
{
return a.value<b.value;
}
};

重载二:
struct node
{
int value;
bool operator < (const node &n) const
{
return n.value<value;
}
};

优先队列:
priority_queue<int,vector<int>,greater<int> >q;//最小优先
priority_queue<int,vector<int>,less<int> >q1;//最大优先
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息