Trait imbl_sized_chunks::ring_buffer::Array
source · pub trait Array: HasLength + Index<usize> {
// Provided methods
fn get(&self, index: usize) -> Option<&Self::Output> { ... }
fn first(&self) -> Option<&Self::Output> { ... }
fn last(&self) -> Option<&Self::Output> { ... }
fn contains(&self, target: &Self::Output) -> bool
where Self::Output: PartialEq { ... }
fn binary_search(&self, target: &Self::Output) -> Result<usize, usize>
where Self::Output: Ord { ... }
fn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
where F: FnMut(&Self::Output) -> Ordering { ... }
fn binary_search_by_key<K, F>(
&self,
key: &K,
extract: F
) -> Result<usize, usize>
where F: FnMut(&Self::Output) -> K,
K: Ord { ... }
fn is_sorted(&self) -> bool
where Self::Output: PartialOrd { ... }
fn is_sorted_by<F>(&self, compare: F) -> bool
where F: FnMut(&Self::Output, &Self::Output) -> Option<Ordering> { ... }
fn is_sorted_by_key<K, F>(&self, extract: F) -> bool
where F: FnMut(&Self::Output) -> K,
K: PartialOrd { ... }
fn starts_with(&self, slice: &[Self::Output]) -> bool
where Self::Output: PartialEq + Sized { ... }
fn ends_with(&self, slice: &[Self::Output]) -> bool
where Self::Output: PartialEq + Sized { ... }
}
Expand description
Trait for data structures which are indexed like arrays.
Types implementing this trait must have populated indexes from
0
up to but not including self.len()
.
Provided Methods§
sourcefn get(&self, index: usize) -> Option<&Self::Output>
fn get(&self, index: usize) -> Option<&Self::Output>
Get a reference to the element at the given index.
sourcefn contains(&self, target: &Self::Output) -> bool
fn contains(&self, target: &Self::Output) -> bool
Return true if an element equivalent to target
exists in the array.
sourcefn binary_search(&self, target: &Self::Output) -> Result<usize, usize>
fn binary_search(&self, target: &Self::Output) -> Result<usize, usize>
Perform a binary search for target
.
sourcefn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
fn binary_search_by<F>(&self, compare: F) -> Result<usize, usize>
Perform a binary search using a comparator function.
sourcefn binary_search_by_key<K, F>(
&self,
key: &K,
extract: F
) -> Result<usize, usize>
fn binary_search_by_key<K, F>( &self, key: &K, extract: F ) -> Result<usize, usize>
Perform a binary search using a key and a key extractor function.
sourcefn is_sorted(&self) -> boolwhere
Self::Output: PartialOrd,
fn is_sorted(&self) -> boolwhere
Self::Output: PartialOrd,
Test whether the array is sorted.
sourcefn is_sorted_by<F>(&self, compare: F) -> bool
fn is_sorted_by<F>(&self, compare: F) -> bool
Test whether the array is sorted using a comparator function.
sourcefn is_sorted_by_key<K, F>(&self, extract: F) -> bool
fn is_sorted_by_key<K, F>(&self, extract: F) -> bool
Test whether the array is sorted using a key extractor function.
sourcefn starts_with(&self, slice: &[Self::Output]) -> bool
fn starts_with(&self, slice: &[Self::Output]) -> bool
Test whether the array starts with the elements in slice
.
Object Safety§
This trait is not object safe.