Trait SliceBisectExt

Source
pub trait SliceBisectExt<T> {
    // Required methods
    fn find_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>;
    fn rfind_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>;
    fn position_bisect(&self, f: impl FnMut(&T) -> bool) -> usize;
    fn rposition_bisect(&self, f: impl FnMut(&T) -> bool) -> usize;
}
Expand description

binary search for slice

Required Methods§

Source

fn find_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>

Returns the first element that satisfies a predicate.

Source

fn rfind_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>

Returns the last element that satisfies a predicate.

Source

fn position_bisect(&self, f: impl FnMut(&T) -> bool) -> usize

Returns the first index that satisfies a predicate. if not found, returns len().

Source

fn rposition_bisect(&self, f: impl FnMut(&T) -> bool) -> usize

Returns the last index+1 that satisfies a predicate. if not found, returns 0.

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> SliceBisectExt<T> for [T]

Source§

fn find_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>

Source§

fn rfind_bisect(&self, f: impl FnMut(&T) -> bool) -> Option<&T>

Source§

fn position_bisect(&self, f: impl FnMut(&T) -> bool) -> usize

Source§

fn rposition_bisect(&self, f: impl FnMut(&T) -> bool) -> usize

Implementors§