我对优先队列的定义是:
template<typename Node, typename Cmp = std::less<Node> >
struct deref_compare : std::binary_function<Node*,Node*,bool>
{
deref_compare(Cmp const& cmp = Cmp())
: cmp(cmp) {}
bool operator()(Node* a, Node* b) const {
return (a->getfValue()> b->getfValue());
}
private:
Cmp cmp;
};
typedef deref_compare<Node,std::greater<Node> > my_comparator_t;
priority_queue<Node*,vector<Node*>,my_comparator_t> openq;
我在做:
openq.push(myNode)
进入 3-4 个节点后,我遇到了分段错误。
mynode
不是空的。
我该如何解决?