pub struct BinarySearchExtension;Expand description
Binary searching of a list with a comparer.
Unlike slice::binary_search_by, which may return any of several equal
items, the search visits the items in a fixed order. The result is the
index of the found item or the bitwise complement of the index of the
next larger item.
Implementations§
Source§impl BinarySearchExtension
impl BinarySearchExtension
Sourcepub fn binary_search<T>(
list: &[T],
value: &T,
comparer: impl Fn(&T, &T) -> Ordering,
) -> i32
pub fn binary_search<T>( list: &[T], value: &T, comparer: impl Fn(&T, &T) -> Ordering, ) -> i32
Performs a binary search on the entire contents of a list.
Returns the index of the found item; otherwise the bitwise complement of the index of the next larger item.
Sourcepub fn binary_search_range<T>(
list: &[T],
index: i32,
length: i32,
value: &T,
comparer: impl Fn(&T, &T) -> Ordering,
) -> i32
pub fn binary_search_range<T>( list: &[T], index: i32, length: i32, value: &T, comparer: impl Fn(&T, &T) -> Ordering, ) -> i32
Performs a binary search on a subset of a list: length items
starting at index.
Returns the index of the found item; otherwise the bitwise complement of the index of the next larger item.
Auto Trait Implementations§
impl Freeze for BinarySearchExtension
impl RefUnwindSafe for BinarySearchExtension
impl Send for BinarySearchExtension
impl Sync for BinarySearchExtension
impl Unpin for BinarySearchExtension
impl UnsafeUnpin for BinarySearchExtension
impl UnwindSafe for BinarySearchExtension
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
The static constructor of a type: work done once per thread, after
the properties of the type are registered and before its first
instance exists (class handlers,
affects_render, metadata
overrides). Read more