Closed
Description
Consider a BinaryHeap in which we need to change priority of some elements. For the moment, this only way to implement this is to drain the heap and rebuild it from scratch. It would be more efficient to be able to remove only the affected elements, so as to read them.
A variant would be a
/// If `f(foo)` returns `Some(bar)`, replace `foo` with `bar`, which may have a different priority.
fn replace<F>(&mut self, f: F) where F: FnMut(&T) -> Option<T>;