pub fn occurs_multiple<T>(sasc: &[T], sdesc: &[T], val: T) -> usize where
    T: PartialOrd + Copy
Expand description

Counts occurrences of val, using previously obtained ascending explicit sort sasc and descending sort sdesc. The two sorts must be of the same original set! This is to facilitate counting of many different values without having to repeat the sorting. This function is efficient at counting numerous repetitions in large sets (e.g. probabilities in stats). Binary search from both ends is deployed: O(2log(n)).

Example:

use crate::indxvec::Indices;
use indxvec::merge::{sortidx,occurs_multiple};
let s = [3.141,3.14159,3.14159,3.142];
let sindx = sortidx(&s); // only one sorting
let sasc = sindx.unindex(&s,true);   // explicit ascending
let sdesc = sindx.unindex(&s,false); // explicit descending
assert_eq!(occurs_multiple(&sasc,&sdesc,3.14159),2);