I have a priority queue of pointers to a struct city
. I modify the objects pointed by these pointers outside the priority queue, and want to tell the priority q
If you need to keep an ordered collection you may consider the following solution: Use std::set
and to update values remove the item, update its value and place it back into the set. This will give you O(log n) complexity for updating one item, which is the best you can in a usual heap structure (Assuming you had access to its internals to mass with the sift-up sift-down procedures).
The only downside to std::set
will be the time for initializing a set with n items. (O(n log n) instead of O(n)).