STL priority queue and overloading with pointers

前端 未结 2 644
北海茫月
北海茫月 2021-01-05 14:05

This is my first time using a priority queue. I\'m trying to implement Dijkstra\'s algorithm for school and I figured I need a min heap to do this. Right now my nodes are po

2条回答
  •  猫巷女王i
    2021-01-05 15:08

    You would need your comparison functor to implement bool operator()(....), not bool operator<(....):

    struct node_comparison 
    {
       bool operator()( const Node* a, const Node* b ) const 
       {
        return a->totalWeight < b->totalWeight;
       }
    };
    

提交回复
热议问题