Trait tor_basic_utils::BinaryHeapExt
source · pub trait BinaryHeapExt<T> {
fn retain_ext<F: FnMut(&T) -> bool>(&mut self, f: F);
}
Expand description
Implementation of BinaryHeap::retain
that doesn’t require Nightly
Required Methods§
sourcefn retain_ext<F: FnMut(&T) -> bool>(&mut self, f: F)
fn retain_ext<F: FnMut(&T) -> bool>(&mut self, f: F)
Remove all elements for which f
returns false
Performance is not great right now - the algorithm is O(n*log(n))
where n
is the number of elements in the heap (not the number removed).
The name is retain_ext
to avoid a name collision with the unstable function,
which would require the use of UFCS and make this unergonomic.