[−][src]Function bisection::bisect_left_slice_by
pub fn bisect_left_slice_by<T, I, F>(a: &[T], within: I, f: F) -> usize where
I: RangeBounds<usize>,
F: FnMut(&T) -> Ordering,
Return the index where a value should be inserted in a[within]
, assuming it sorted,
according to a comparator function.
The comparator function should implement an order consistent with the sort order of the
underlying slice, returning an order code that indicates whethers its argument is Less
,
Equal
or Greater
that the desired target.
The return value i
is such that all e
in a[..i]
have f(e) == Less
, and
all e
in a[i..]
have f(e) == Greater | f(e) == Equal
- If
a
containsx
,a.insert(i, x)
will insert just before the leftmostx
.
Panics
Panics if within
is out of bounds of a
.