less<vector<Node*>::value_type>
Means that your comparator compares the pointers to each other, meaning your vector will be sorted by the layout in memory of the nodes.
You want to do something like this:
#include <functional>
struct DereferenceCompareNode : public std::binary_function<Node*, Node*, bool>
{
bool operator()(const Node* lhs, const Node* rhs) const
{
return lhs->getTotalCost() < rhs->getTotalCost();
}
};
// later...
priority_queue<Node*, vector<Node*>, DereferenceCompareNode> nodesToCheck;
Note that you need to be const-correct in your definition of totalCost
.
EDIT: Now that C++11 is here, you don't need to inherit from std::binary_function anymore (which means you don't need to #include functional)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…