Function librualg::binary_search::lower_bound[][src]

pub fn lower_bound<T>(container: &[T], key: &T) -> Option<usize> where
    T: Ord

Binary search algorithm. Returns the leftmost position of the item to find. It is necessary that the container is pre-sorted

 use librualg::binary_search::lower_bound;

 let seq = vec![1, 2, 3, 4, 5, 8, 8, 8, 9, 20];

 assert_eq!(lower_bound(&seq, &8).unwrap(), 5);
 assert_eq!(lower_bound(&seq, &7), None);