April 28, 2014 change value of item in BinaryHeap | ||||
---|---|---|---|---|
| ||||
I am trying to figure out how to change the value of an element in a BinaryHeap (from std.container) and have it repositioned such that the heap is still valid. Can anyone help me with this? The approach I would have taken (I think) is to remove the elements that get new values from the heap, and simply re-insert them, but I cannot find a function that can allow me to remove an arbitrary element Use-case is implementing Visvalingam's algorithm for shape simplification. I need to always select the element (point on shape) of lowest value (area between it and 2 surrounding points), but doing so changes the value (area) of the 2 surrounding points, and they have to be repositioned in the heap.. |
Copyright © 1999-2021 by the D Language Foundation