pub trait OrderedKeyMap<T>: ExtKeyMap<T>{
type Range<'a>: Iterator<Item = (Self::Key, &'a T)> + DoubleEndedIterator
where Self: 'a,
T: 'a;
type RangeMut<'a>: Iterator<Item = (Self::Key, &'a mut T)> + DoubleEndedIterator
where Self: 'a,
T: 'a;
// Required methods
fn range<R: RangeBounds<Self::Key>>(&self, range: R) -> Self::Range<'_>;
fn range_mut<R: RangeBounds<Self::Key>>(
&mut self,
range: R,
) -> Self::RangeMut<'_>;
// Provided methods
fn first(&self) -> Option<(Self::Key, &T)> { ... }
fn first_mut(&mut self) -> Option<(Self::Key, &mut T)> { ... }
fn last(&self) -> Option<(Self::Key, &T)> { ... }
fn last_mut(&mut self) -> Option<(Self::Key, &mut T)> { ... }
}Expand description
A trait for maps that have strongly ordered keys and provide iterators over key ranges.
The most notable example of such a map is the BTreeMap.
Required Associated Types§
Required Methods§
Sourcefn range<R: RangeBounds<Self::Key>>(&self, range: R) -> Self::Range<'_>
fn range<R: RangeBounds<Self::Key>>(&self, range: R) -> Self::Range<'_>
Returns an immutable iterator over entries corresponding to keys in the specified range.
Sourcefn range_mut<R: RangeBounds<Self::Key>>(
&mut self,
range: R,
) -> Self::RangeMut<'_>
fn range_mut<R: RangeBounds<Self::Key>>( &mut self, range: R, ) -> Self::RangeMut<'_>
Returns a mutable iterator over entries corresponding to keys in the specified range.
Provided Methods§
Sourcefn first(&self) -> Option<(Self::Key, &T)>
fn first(&self) -> Option<(Self::Key, &T)>
Returns an immutable reference to the first element in the map.
§Default behavior
The default implementation takes the first element returned by the range iterator on an unbounded range.
Sourcefn first_mut(&mut self) -> Option<(Self::Key, &mut T)>
fn first_mut(&mut self) -> Option<(Self::Key, &mut T)>
Returns a mutable reference to the first element in the map.
§Default behavior
The default implementation takes the first element returned by the range iterator on an unbounded range.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<K: Copy + Eq + Ord + Debug + 'static, T> OrderedKeyMap<T> for BTreeMap<K, T>
Available on crate feature alloc only.
impl<K: Copy + Eq + Ord + Debug + 'static, T> OrderedKeyMap<T> for BTreeMap<K, T>
alloc only.