bisect_left

Function bisect_left 

Source
pub fn bisect_left<T: Ord>(data: &[T], x: &T) -> usize
Expand description

Returns the leftmost insertion point for x in a sorted slice.

If x is already present, returns the index before any existing entries.

ยงExample

use d3rs::array::bisect_left;

let data = vec![1, 2, 3, 3, 3, 5, 8];
assert_eq!(bisect_left(&data, &3), 2);
assert_eq!(bisect_left(&data, &4), 5);