Function librualg::binary_search::upper_bound[][src]

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

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

 use librualg::binary_search::upper_bound;

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

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