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>
impl<K, V> RangeMap2<K, V>
Sourcepub fn get(&self, key: K) -> Option<(&Range<K>, &V)>
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.
Sourcepub fn last_range(&self) -> Option<&Range<K>>
pub fn last_range(&self) -> Option<&Range<K>>
The last range stored in this map.
Sourcepub fn remove(&mut self, range: Range<K>) -> Vec<V>
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.
Sourcepub fn insert(&mut self, range: Range<K>, value: V)
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.
Sourcepub fn iter_starting_at(&self, key: K) -> impl Iterator<Item = (&Range<K>, &V)>
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.
Sourcepub fn iter_ending_at(
&self,
key: K,
) -> impl DoubleEndedIterator<Item = (&Range<K>, &V)>
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.