Trait BinaryHeapExt

Source
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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

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§