我需要在我的项目中使用Fibonacci堆,我试图从boost库中使用它.但我无法弄清楚如何为任意数据类型设置用户定义的比较函数.我需要为struct node构造一个min heap,如下所示:
struct node
{
int id;
int weight;
struct node* next;
/* dist is a global array of integers */
bool operator > (struct node b) //Boost generates a Max-heap. What I need is a min-heap.
{return dist[id] < dist[b.id] ? 1:0 ;} //That's why "<" is used for "operator >".
bool operator < (struct node b)
{return dist[id] > dist[b.id] ? 1:0 ;}
bool operator >=(struct node b)
{return dist[id] <= dist[b.id] ? 1:0 ;}
bool operator …Run Code Online (Sandbox Code Playgroud)