开发者

Managing a priority queue?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜