1

I want to implement the Fast Tagging algorithm described in Section 5.2 of http://physbam.stanford.edu/~fedkiw/papers/stanford2001-03.pdf. Here, they claim to use a binary heap for sorting operations, so I thought it could be a good idea to use the sort_heap method of the standard library as explained here:

http://www.cplusplus.com/reference/algorithm/sort_heap/

in this example the vector to be sorted contains just integer values while in my case I have a distance map defined on a 3D grid (linearized into a 1D array) and, since I have to know the index corresponding to a particular distance value, I should use something like:

std::vector<std::pair<int,float>> v;

In this thread

How do I sort a vector of pairs based on the second element of the pair?

it's shown how to call std::sort for a similar problem, is it possible to do the same for std::sort_heap?

Thanks!


Edit

As T.C. pointed out this problem can be solved by using a priority_queue!

Community
  • 1
  • 1
Federico Nardi
  • 510
  • 7
  • 19

0 Answers0