[−][src]Trait math::search::binary_search::BinarySearch
Required methods
pub fn binary_search_with_cmp<E, F>(
&self,
start: usize,
end: usize,
target: &E,
cmp: F
) -> Result<usize, Option<usize>> where
F: Fn(&Self::Output, &E) -> Ordering,
[src]
&self,
start: usize,
end: usize,
target: &E,
cmp: F
) -> Result<usize, Option<usize>> where
F: Fn(&Self::Output, &E) -> Ordering,
performs binary search between the start
and end
indices
start
: start index
end
: end index exclusive
cmp
: a function that returns Ordering::Less
when the first argument
is less than the second, etc. returns the index of the target
element as Some(usize)
if present, Err
otherwise. In the case of
returning an Err
, the associated value is Some(usize)
representing the index at which the target value can be inserted while
maintaining the sorted order, or None
if the provided [start, end)
range is empty, i.e. when start >= end
.
Implementations on Foreign Types
impl<T> BinarySearch for Vec<T>
[src]
pub fn binary_search_with_cmp<E, F>(
&self,
start: usize,
end_exclusive: usize,
target: &E,
cmp: F
) -> Result<usize, Option<usize>> where
F: Fn(&Self::Output, &E) -> Ordering,
[src]
&self,
start: usize,
end_exclusive: usize,
target: &E,
cmp: F
) -> Result<usize, Option<usize>> where
F: Fn(&Self::Output, &E) -> Ordering,