Function search_sort::search::jump[][src]

pub fn jump<T: Ord>(slice: &[T], value: &T) -> Option<usize>
Expand description

An implementation of jump search with optimal step.

Invokes jump_step search with square root of the length of the slice. It does (len / step) + step - 1 comparisions at most; there would be the least of them if step = sqrt(len).

Examples

use search_sort::search;

let slice = [1, 5, 7, 15, 31, 32, 45];
assert_eq!(search::jump(&slice, &15), Some(3));