pub trait BinaryHeapExt<T> {
    // Required method
    fn retain_ext<F: FnMut(&T) -> bool>(&mut self, f: F);
}
Expand description

Implementation of BinaryHeap::retain that doesn’t require Nightly

Required Methods§

source

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.

Implementations on Foreign Types§

source§

impl<T: Ord> BinaryHeapExt<T> for BinaryHeap<T>

source§

fn retain_ext<F: FnMut(&T) -> bool>(&mut self, f: F)

Implementors§