Struct RangeMap2

Source
pub struct RangeMap2<K: Ord + Copy, V: Clone + Eq> { /* private fields */ }
Expand description

A map from ranges to values.

This map can be cloned efficiently. If the map is modified after being cloned, the relevant parts of the map’s internal structure will be copied lazily.

Implementations§

Source§

impl<K, V> RangeMap2<K, V>
where K: Ord + Copy, V: Clone + Eq,

Source

pub fn is_empty(&self) -> bool

Whether this map contains any entries.

Source

pub fn get(&self, key: K) -> Option<(&Range<K>, &V)>

Searches the map for a range that contains the given key.

Returns the range and value if such a range is found.

Source

pub fn last_range(&self) -> Option<&Range<K>>

The last range stored in this map.

Source

pub fn remove(&mut self, range: Range<K>) -> Vec<V>

Remove the entry with the given key from the map.

If the key was present in the map, returns the value previously stored at the given key.

Source

pub fn insert(&mut self, range: Range<K>, value: V)

Inserts a range with the given value.

The keys included in the given range are now associated with the given value. If those keys were previously associated with another value, are no longer associated with that previous value.

This method can cause one or more values in the map to be dropped if the all of the keys associated with those values are contained within the given range.

If the inserted range is directly adjacent to another range with an equal value, the inserted range will be merged with the adjacent ranges.

Source

pub fn iter(&self) -> Iter<'_, K, V>

Iterate through the keys and values stored in the map.

Source

pub fn iter_starting_at(&self, key: K) -> impl Iterator<Item = (&Range<K>, &V)>

Iterate over the ranges in the map, starting at the first range starting after or at the given point.

Source

pub fn iter_ending_at( &self, key: K, ) -> impl DoubleEndedIterator<Item = (&Range<K>, &V)>

Iterate over the ranges in the map, starting at the last range starting before or at the given point.

Source

pub fn intersection( &self, range: impl Borrow<Range<K>>, ) -> impl DoubleEndedIterator<Item = (&Range<K>, &V)>

Trait Implementations§

Source§

impl<K: Clone + Ord + Copy, V: Clone + Clone + Eq> Clone for RangeMap2<K, V>

Source§

fn clone(&self) -> RangeMap2<K, V>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + Ord + Copy, V: Debug + Clone + Eq> Debug for RangeMap2<K, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V> Default for RangeMap2<K, V>
where K: Ord + Copy, V: Clone + Eq,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<K, V> Freeze for RangeMap2<K, V>

§

impl<K, V> RefUnwindSafe for RangeMap2<K, V>

§

impl<K, V> Send for RangeMap2<K, V>
where K: Sync + Send, V: Sync + Send,

§

impl<K, V> Sync for RangeMap2<K, V>
where K: Sync + Send, V: Sync + Send,

§

impl<K, V> Unpin for RangeMap2<K, V>

§

impl<K, V> UnwindSafe for RangeMap2<K, V>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.