Trait OrderedKeyMap

Source
pub trait OrderedKeyMap<T>: ExtKeyMap<T>
where Self::Key: Ord,
{ 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§

Source

type Range<'a>: Iterator<Item = (Self::Key, &'a T)> + DoubleEndedIterator where Self: 'a, T: 'a

The type for an immutable range iterator for the map.

Source

type RangeMut<'a>: Iterator<Item = (Self::Key, &'a mut T)> + DoubleEndedIterator where Self: 'a, T: 'a

The type for a mutable range iterator for the map.

Required Methods§

Source

fn range<R: RangeBounds<Self::Key>>(&self, range: R) -> Self::Range<'_>

Returns an immutable iterator over entries corresponding to keys in the specified range.

Source

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§

Source

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.

Source

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.

Source

fn last(&self) -> Option<(Self::Key, &T)>

Returns an immutable reference to the last element in the map.

§Default behavior

The default implementation takes the last element returned by the range iterator on an unbounded range.

Source

fn last_mut(&mut self) -> Option<(Self::Key, &mut T)>

Returns a mutable reference to the last element in the map.

§Default behavior

The default implementation takes the last 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.
Source§

type Range<'a> = Map<Range<'a, K, T>, fn((&'a K, &'a T)) -> (K, &'a T)> where Self: 'a

Source§

type RangeMut<'a> = Map<RangeMut<'a, K, T>, fn((&'a K, &'a mut T)) -> (K, &'a mut T)> where Self: 'a

Source§

fn range<R: RangeBounds<Self::Key>>(&self, range: R) -> Self::Range<'_>

Source§

fn range_mut<R: RangeBounds<Self::Key>>( &mut self, range: R, ) -> Self::RangeMut<'_>

Source§

fn first(&self) -> Option<(K, &T)>

Source§

fn first_mut(&mut self) -> Option<(K, &mut T)>

Source§

fn last(&self) -> Option<(K, &T)>

Source§

fn last_mut(&mut self) -> Option<(K, &mut T)>

Implementors§