Expand description
Counts occurrences of val, using previously obtained
ascending explicit sort sasc
and descending sort sdesc
.
This is to facilitate counting of many
different values without ever having to repeat the sorting.
This function is very 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};
let s = [3.141,3.14159,3.14159,3.142];
let sindx = sortidx(&s); // only one sort ever
let sasc = sindx.unindex(&s,true);
let sdesc = sindx.unindex(&s,false);
assert_eq!(occurs(&sasc,&sdesc,3.14159),2);