Struct rangemap::RangeMap [−][src]
A map whose keys are stored as (half-open) ranges bounded
inclusively below and exclusively above (start..end)
.
Contiguous and overlapping ranges that map to the same value are coalesced into a single range.
Implementations
impl<K, V> RangeMap<K, V> where
K: Ord + Clone,
V: Eq + Clone,
[src]
K: Ord + Clone,
V: Eq + Clone,
pub fn new() -> Self
[src]
Makes a new empty RangeMap
.
pub fn get(&self, key: &K) -> Option<&V>
[src]
Returns a reference to the value corresponding to the given key, if the key is covered by any range in the map.
pub fn get_key_value(&self, key: &K) -> Option<(&Range<K>, &V)>
[src]
Returns the range-value pair (as a pair of references) corresponding to the given key, if the key is covered by any range in the map.
pub fn contains_key(&self, key: &K) -> bool
[src]
Returns true
if any range in the map covers the specified key.
pub fn iter(&self) -> impl Iterator<Item = (&Range<K>, &V)>
[src]
Gets an iterator over all pairs of key range and value, ordered by key range.
The iterator element type is (&'a Range<K>, &'a V)
.
pub fn insert(&mut self, range: Range<K>, value: V)
[src]
Insert a pair of key range and value into the map.
If the inserted range partially or completely overlaps any existing range in the map, then the existing range (or ranges) will be partially or completely replaced by the inserted range.
If the inserted range either overlaps or is immediately adjacent any existing range mapping to the same value, then the ranges will be coalesced into a single contiguous range.
Panics
Panics if range start >= end
.
pub fn remove(&mut self, range: Range<K>)
[src]
Removes a range from the map, if all or any of it was present.
If the range to be removed partially overlaps any ranges in the map, then those ranges will be contracted to no longer cover the removed range.
Panics
Panics if range start >= end
.
pub fn gaps<'a>(&'a self, outer_range: &'a Range<K>) -> Gaps<'a, K, V>
[src]
Gets an iterator over all the maximally-sized ranges
contained in outer_range
that are not covered by
any range stored in the map.
The iterator element type is Range<K>
.
NOTE: Calling gaps
eagerly finds the first gap,
even if the iterator is never consumed.
Trait Implementations
impl<K: Clone, V: Clone> Clone for RangeMap<K, V>
[src]
impl<K: Debug, V: Debug> Debug for RangeMap<K, V> where
K: Ord + Clone,
V: Eq + Clone,
[src]
K: Ord + Clone,
V: Eq + Clone,
impl<K, V> Default for RangeMap<K, V> where
K: Ord + Clone,
V: Eq + Clone,
[src]
K: Ord + Clone,
V: Eq + Clone,
Auto Trait Implementations
impl<K, V> RefUnwindSafe for RangeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for RangeMap<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for RangeMap<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Unpin for RangeMap<K, V>
impl<K, V> UnwindSafe for RangeMap<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,