Function indxvec::search_all

source ·
pub fn search_all<T, U>(
    rng: Range<T>,
    sample: &mut impl FnMut(&T) -> U,
    target: U
) -> Range<T>where
    T: PartialOrd + Copy + From<u8> + Add<Output = T> + Sub<Output = T> + Div<Output = T> + Mul<Output = T>,
    U: PartialOrd,
Expand description

General Binary Search with fast method for finding all the matches.
Search within the specified Range index, which is always ascending.
The (indexing) range values can be of any generic type T satisfying the listed bounds. Typically usize for indexing efficiently in-memory, u128 for searching whole disks or internet, f64 for solving equations which might not converge using secant and other methods.
Closure samples the (sorted) data source.
Target is the value to be found.
The sort order of the data can be either ascending or descending (increasing/decreasing) and is automatically detected.
When the target is in order before self.start, empty self self.start..self.start range is returned. When the target is in order after self.end, self.end..self.end is returned. When target is not found, then an empty range with its start (and end) equal to the sort position is returned. Otherwise returns the range of all the consecutive values PartiallyEqual to the target.