自定义比较-结构体,优先队列,快排

https://blog.csdn.net/tsam123/article/details/85220284

本来想总结一下的,然后发现这篇文章总结的挺好。

另外里面的重载对快排同样也有效。

只是要注意以下谁在前谁在后。

friend bool operator < (struct node a, struct node b)
	{
		if (a.price != b.price)	return a.price < b.price;
		else return a.time < b.time;
	}//使用小于号,对于优先队列,效果是price大的靠近top;对于sort函数,会把price小的排在数组前面
posted @ 2021-11-20 11:56  tsrigo  阅读(18)  评论(0编辑  收藏  举报