flatqueue icon indicating copy to clipboard operation
flatqueue copied to clipboard

Add support for updating priority of entry

Open nermin99 opened this issue 4 years ago • 2 comments

Since I'm trying to implement Dijkstra's algorithm, I want to be able to update the priority of an already existing entry in the queue.

nermin99 avatar Dec 22 '21 15:12 nermin99

BTW, while having a direct method to update priority of an existing value will be ideal, it may be costly — for Dijkstra, a simpler approach may be to just add a duplicate node. Once we pop a node (which means it's the highest priority), any subsequent duplicates can be ignored.

mourner avatar Mar 30 '22 07:03 mourner

I have an application where the update is changing the points priority in the other direction (ie increasing the priority of some points). To solve this I maintain an external array of priorities. When I pop a value, if its priority in the queue doesn't match the priority in the array (in other words, if it has been modified), I ignore it and push it back with the updated value.

Fil avatar Feb 11 '23 17:02 Fil