Sign in to follow this  

my compare function is broken!

This topic is 3576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites

This topic is 3576 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this