Search code examples
c++stlcontainersa-star

c++ set versus vector + heap operations for an A* priority queue


When is using a std::set more efficient (w.r.t. time) than using a std::vector along with make_heap/push_/pop_ for the priority queue in an A* operation? My guess is that if the vertices in the open list are small, using a vector is a better option. But does anyone have experience with this?


Solution

  • If i had to venture a guess? I'd guess that the vector version is probably a good choice because once it grows to a certain size, there won't be very many allocs.

    But I don't like guessing. I prefer hard numbers. Try both, profile!