pub struct Slice<K, V> { /* private fields */ }
Expand description
Implementations§
Source§impl<K, V> Slice<K, V>
impl<K, V> Slice<K, V>
Sourcepub fn get_index(&self, index: usize) -> Option<(&K, &V)>
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
Get a key-value pair by index.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
Get a key-value pair by index, with mutable access to the value.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self>
pub fn get_range<R: RangeBounds<usize>>(&self, range: R) -> Option<&Self>
Returns a slice of key-value pairs in the given range of indices.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn get_range_mut<R: RangeBounds<usize>>(
&mut self,
range: R,
) -> Option<&mut Self>
pub fn get_range_mut<R: RangeBounds<usize>>( &mut self, range: R, ) -> Option<&mut Self>
Returns a mutable slice of key-value pairs in the given range of indices.
Valid indices are 0 <= index < self.len()
.
Sourcepub fn first_mut(&mut self) -> Option<(&K, &mut V)>
pub fn first_mut(&mut self) -> Option<(&K, &mut V)>
Get the first key-value pair, with mutable access to the value.
Sourcepub fn last_mut(&mut self) -> Option<(&K, &mut V)>
pub fn last_mut(&mut self) -> Option<(&K, &mut V)>
Get the last key-value pair, with mutable access to the value.
Sourcepub fn split_at(&self, index: usize) -> (&Self, &Self)
pub fn split_at(&self, index: usize) -> (&Self, &Self)
Divides one slice into two at an index.
Panics if index > len
.
Sourcepub fn split_at_mut(&mut self, index: usize) -> (&mut Self, &mut Self)
pub fn split_at_mut(&mut self, index: usize) -> (&mut Self, &mut Self)
Divides one mutable slice into two at an index.
Panics if index > len
.
Sourcepub fn split_first(&self) -> Option<((&K, &V), &Self)>
pub fn split_first(&self) -> Option<((&K, &V), &Self)>
Returns the first key-value pair and the rest of the slice,
or None
if it is empty.
Sourcepub fn split_first_mut(&mut self) -> Option<((&K, &mut V), &mut Self)>
pub fn split_first_mut(&mut self) -> Option<((&K, &mut V), &mut Self)>
Returns the first key-value pair and the rest of the slice,
with mutable access to the value, or None
if it is empty.
Sourcepub fn split_last(&self) -> Option<((&K, &V), &Self)>
pub fn split_last(&self) -> Option<((&K, &V), &Self)>
Returns the last key-value pair and the rest of the slice,
or None
if it is empty.
Sourcepub fn split_last_mut(&mut self) -> Option<((&K, &mut V), &mut Self)>
pub fn split_last_mut(&mut self) -> Option<((&K, &mut V), &mut Self)>
Returns the last key-value pair and the rest of the slice,
with mutable access to the value, or None
if it is empty.
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Return an iterator over the key-value pairs of the map slice.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
Return an iterator over the key-value pairs of the map slice.
Sourcepub fn into_keys(self: Box<Self>) -> IntoKeys<K, V> ⓘ
pub fn into_keys(self: Box<Self>) -> IntoKeys<K, V> ⓘ
Return an owning iterator over the keys of the map slice.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Return an iterator over the values of the map slice.
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
Return an iterator over mutable references to the the values of the map slice.
Sourcepub fn into_values(self: Box<Self>) -> IntoValues<K, V> ⓘ
pub fn into_values(self: Box<Self>) -> IntoValues<K, V> ⓘ
Return an owning iterator over the values of the map slice.
Sourcepub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
Search over a sorted map for a key.
Returns the position where that key 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 key up in
the map this is a slice from using IndexMap::get_index_of
, but this can also position
missing keys.
Sourcepub 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 map 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.
Sourcepub 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 map 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.
Sourcepub 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 map 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§
Source§impl<'a, K, V> IntoIterator for &'a Slice<K, V>
impl<'a, K, V> IntoIterator for &'a Slice<K, V>
Source§impl<'a, K, V> IntoIterator for &'a mut Slice<K, V>
impl<'a, K, V> IntoIterator for &'a mut Slice<K, V>
Source§impl<K, V> IntoIterator for Box<Slice<K, V>>
impl<K, V> IntoIterator for Box<Slice<K, V>>
Source§impl<K: PartialOrd, V: PartialOrd> PartialOrd for Slice<K, V>
impl<K: PartialOrd, V: PartialOrd> PartialOrd for Slice<K, V>
impl<K: Eq, V: Eq> Eq for Slice<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Slice<K, V>
impl<K, V> RefUnwindSafe for Slice<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for Slice<K, V>
impl<K, V> !Sized for Slice<K, V>
impl<K, V> Sync for Slice<K, V>
impl<K, V> Unpin for Slice<K, V>
impl<K, V> UnwindSafe for Slice<K, V>where
K: UnwindSafe,
V: 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
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.