Struct vector_config::indexmap::set::Slice
pub struct Slice<T> { /* private fields */ }
Expand description
Implementations§
§impl<T> Slice<T>
impl<T> Slice<T>
pub fn get_index(&self, index: usize) -> Option<&T>
pub fn get_index(&self, index: usize) -> Option<&T>
Get a value by index.
Valid indices are 0 <= index < self.len()
.
pub fn get_range<R>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
pub fn get_range<R>(&self, range: R) -> Option<&Slice<T>>where
R: RangeBounds<usize>,
Returns a slice of values in the given range of indices.
Valid indices are 0 <= index < self.len()
.
pub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)
pub fn split_at(&self, index: usize) -> (&Slice<T>, &Slice<T>)
Divides one slice into two at an index.
Panics if index > len
.
pub fn split_first(&self) -> Option<(&T, &Slice<T>)>
pub fn split_first(&self) -> Option<(&T, &Slice<T>)>
Returns the first value and the rest of the slice,
or None
if it is empty.
pub fn split_last(&self) -> Option<(&T, &Slice<T>)>
pub fn split_last(&self) -> Option<(&T, &Slice<T>)>
Returns the last value and the rest of the slice,
or None
if it is empty.
pub fn binary_search(&self, x: &T) -> Result<usize, usize>where
T: Ord,
pub fn binary_search(&self, x: &T) -> Result<usize, usize>where
T: Ord,
Search over a sorted set for a value.
Returns the position where that value is present, or the position where it can be inserted
to maintain the sort. See slice::binary_search
for more details.
Computes in O(log(n)) time, which is notably less scalable than looking the value up in
the set this is a slice from using IndexSet::get_index_of
, but this can also position
missing values.
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
Search over a sorted set with a comparator function.
Returns the position where that value is present, or the position where it can be inserted
to maintain the sort. See slice::binary_search_by
for more details.
Computes in O(log(n)) time.
pub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F,
) -> Result<usize, usize>
pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
Search over a sorted set with an extraction function.
Returns the position where that value is present, or the position where it can be inserted
to maintain the sort. See slice::binary_search_by_key
for more details.
Computes in O(log(n)) time.
pub fn partition_point<P>(&self, pred: P) -> usize
pub fn partition_point<P>(&self, pred: P) -> usize
Returns the index of the partition point of a sorted set according to the given predicate (the index of the first element of the second partition).
See slice::partition_point
for more details.
Computes in O(log(n)) time.
Trait Implementations§
§impl<T> Index<RangeInclusive<usize>> for Slice<T>
impl<T> Index<RangeInclusive<usize>> for Slice<T>
§impl<T> Index<RangeToInclusive<usize>> for Slice<T>
impl<T> Index<RangeToInclusive<usize>> for Slice<T>
§impl<'a, T> IntoIterator for &'a Slice<T>
impl<'a, T> IntoIterator for &'a Slice<T>
§impl<T> IntoIterator for Box<Slice<T>>
impl<T> IntoIterator for Box<Slice<T>>
§impl<T> PartialOrd for Slice<T>where
T: PartialOrd,
impl<T> PartialOrd for Slice<T>where
T: PartialOrd,
§impl<T> Serialize for Slice<T>where
T: Serialize,
impl<T> Serialize for Slice<T>where
T: Serialize,
Serializes a set::Slice
as an ordered sequence.
§fn serialize<Se>(
&self,
serializer: Se,
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error>where
Se: Serializer,
fn serialize<Se>(
&self,
serializer: Se,
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error>where
Se: Serializer,
impl<T> Eq for Slice<T>where
T: Eq,
Auto Trait Implementations§
impl<T> Freeze for Slice<T>where
T: Freeze,
impl<T> RefUnwindSafe for Slice<T>where
T: RefUnwindSafe,
impl<T> Send for Slice<T>where
T: Send,
impl<T> !Sized for Slice<T>
impl<T> Sync for Slice<T>where
T: Sync,
impl<T> Unpin for Slice<T>where
T: Unpin,
impl<T> UnwindSafe for Slice<T>where
T: UnwindSafe,
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.