开发者

Managing a priority queue?

开发者 https://www.devze.com 2023-01-20 09:53 出处:网络
I have a structure struct state{ int cur[10]; int next[10]; int priority; }; and a priority queue of these states.How can I manage the priority queue so that fro开发者_高级运维nt element is the ele

I have a structure

struct state{
   int cur[10];
   int next[10];
   int priority;
};

and a priority queue of these states.How can I manage the priority queue so that fro开发者_高级运维nt element is the element with the minimum value of 'priority' ?


Never mind I found the answer http://www.cplusplus.com/reference/stl/priority_queue/priority_queue/

I'll just have to use an external comparator function.

But can someone explain this?

bool operator() (const int& lhs, const int&rhs) const         <<==========
  {
    if (reverse) return (lhs>rhs);
    else return (lhs<rhs);
  }
0

精彩评论

暂无评论...
验证码 换一张
取 消