pub fn binsearch<T>(s: &[T], val: T) -> usize where
    T: PartialOrd<T>, 
Expand description

Binary search of an explicitly sorted list in ascending order. Returns an index of the first item that is greater than val. When none are greater, returns s.len() (invalid index but logical). The complement index (the result subtracted from s.len()), gives the first item in descending order that is not greater than val. Note that both complements of binsearch and binsearchdesc, in their respective opposite orderings, refer to the same preceding item iff there exists precisely one item equal to val. However, there can be more than one such items or none. Example use: looking up cummulative probability density functions.