管理优先级队列?

时间:2010-10-14 07:10:33

标签: c++ data-structures

我有一个结构

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

和这些状态的优先级队列。如何管理优先级队列,以便前元素是最小值为'priority'的元素?

1 个答案:

答案 0 :(得分:3)

没关系,我找到了答案 http://www.cplusplus.com/reference/stl/priority_queue/priority_queue/

我只需要使用外部比较器功能。

但有人可以解释一下吗?

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