Gah!!! No matter what I do, every time I make a correct implementation of this priority queue, when I try to run my program, I get this:
---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Assertion Failed!
Program: ...
File: c:\program files\microsoft visual studio 8\vc\include\algorithm
Line: 2025
Expression: invalid operator<
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------No matter what little tricks I try!
My current predicate looks like this:
struct comp { bool operator() ( const Node* first, const Node* second ) const { if (first->getHeuristic() > second->getHeuristic()) { return true; } else if (second->getOrder() < first->getOrder()) { return true; } else { return false; }; } };
the only way this thing will run is if I make the < in the first else if statement a >, which orders them backwards. What the heck is going on???
i had said in my earlier reply
remember that the predicate must be a relation that is asymetric,
irreflexive and transitive; ie. one that imposes a strict oredering
on the sequence.
because it is important to understand it.
take two nodes
node_a ( getHeuristic returns 10, getOrder returns 6) and
node_b ( getHeuristic returns 11, getOrder returns 5)
comp()(a,b) returns true
if (first->getHeuristic() > second->getHeuristic()) // false
…