I have a PriorityQueue containing references to some objects. When I initially insert the elements into the priority queue the ordering is maintained by the data structure. Now after a remove operation I update some of the references which are being held by the priority queue. Ideally this requires a reheapify operation on the priority queue but as is obvious since I am modifying selected references externally a reheapify cannot be triggered. So what is the best way to ensure that I am able to get the advantage of a heap like fast extract max in the presence of modifications to arbitrary elements inside the queue? I see I need a better data structure?
To be more specific I need an implementation of something like a Fibonacci heap in Java.
http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm
Is that available?
You can use your own tree that allows duplicate elements instead of heap.
Easier though, you can use
TreeMap<PriorityKey, LinkedHashSet<Value>>.All operations are O(log priorityType):
get(priority).add(value), if get returns null,put(priority, new LinkedHashSet())—
Still if you need to change the priority you have to remove and add the element.