Skip to main content
GameDev.net gamedev.net
🔒 Locked

my compare function is broken!

Started by saeedm Mar 4, 2008 at 9:22 PM 0 replies 700+ views
Original Post
saeedm
saeedm
This is my compare function for my heap commands, std::make_heap, etc. bool compareDist(Vertex * a, Vertex * b) { return (a->getDist() < b->getDist()); } and its used in here: make_heap(vertexVector.begin(), vertexVector.end(), compareDist); It should sort the Vertex pointers in my heap by their getDist() values, but instead its almost random. Heres the output of vertexVector before running make_heap: (the format is: vertexnumber=dist) 1=2147483647 2=1 3=21 4=2147483647 5=2147483647 6=2147483647 7=2147483647 And after and running make_heap: 7=2147483647 5=2147483647 6=2147483647 4=2147483647 2=1 1=2147483647 3=21 I tried sort_heap too: 2=1 4=2147483647 5=2147483647 7=2147483647 6=2147483647 3=21 1=2147483647 Thanks for any help
Zakwayda
Zakwayda
Heaps are not organized the way you think they are. (Consult a good reference on the topic for the details :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.