Struct rangemap::RangeInclusiveMap [−][src]
pub struct RangeInclusiveMap<K, V, StepFnsT = K> { /* fields omitted */ }Expand description
A map whose keys are stored as ranges bounded
inclusively below and above (start..=end).
Contiguous and overlapping ranges that map to the same value are coalesced into a single range.
Successor and predecessor functions must be provided for
the key type K, so that we can detect adjacent but non-overlapping
(closed) ranges. (This is not a problem for half-open ranges,
because adjacent ranges can be detected using equality of range ends alone.)
You can provide these functions either by implementing the
StepLite trait for your key type K, or,
if this is impossible because of Rust’s “orphan rules”,
you can provide equivalent free functions using the StepFnsT type parameter.
StepLite is implemented for all standard integer types,
but not for any third party crate types.
Implementations
Makes a new empty RangeInclusiveMap, specifying successor and
predecessor functions defined separately from K itself.
This is useful as a workaround for Rust’s “orphan rules”,
which prevent you from implementing StepLite for K if K
is a foreign type.
NOTE: This will likely be deprecated and then eventually removed once the standard library’s Step trait is stabilised, as most crates will then likely implement Step for their types where appropriate.
See this issue for details about that stabilization process.
Returns a reference to the value corresponding to the given key, if the key is covered by any range in the map.
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.
Returns true if any range in the map covers the specified key.
Gets an iterator over all pairs of key range and value, ordered by key range.
The iterator element type is (&'a RangeInclusive<K>, &'a V).
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.
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.
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 RangeInclusive<K>.
NOTE: Calling gaps eagerly finds the first gap,
even if the iterator is never consumed.
Trait Implementations
impl<K, V> Extend<(RangeInclusive<K>, V)> for RangeInclusiveMap<K, V> where
K: Ord + Clone + StepLite,
V: Eq + Clone,
impl<K, V> Extend<(RangeInclusive<K>, V)> for RangeInclusiveMap<K, V> where
K: Ord + Clone + StepLite,
V: Eq + Clone,
Extends a collection with the contents of an iterator. Read more
extend_one)Extends a collection with exactly one element.
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
impl<K, V> FromIterator<(RangeInclusive<K>, V)> for RangeInclusiveMap<K, V> where
K: Ord + Clone + StepLite,
V: Eq + Clone,
impl<K, V> FromIterator<(RangeInclusive<K>, V)> for RangeInclusiveMap<K, V> where
K: Ord + Clone + StepLite,
V: Eq + Clone,
Creates a value from an iterator. Read more
Auto Trait Implementations
impl<K, V, StepFnsT> RefUnwindSafe for RangeInclusiveMap<K, V, StepFnsT> where
K: RefUnwindSafe,
StepFnsT: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V, StepFnsT> Send for RangeInclusiveMap<K, V, StepFnsT> where
K: Send,
StepFnsT: Send,
V: Send,
impl<K, V, StepFnsT> Sync for RangeInclusiveMap<K, V, StepFnsT> where
K: Sync,
StepFnsT: Sync,
V: Sync,
impl<K, V, StepFnsT> Unpin for RangeInclusiveMap<K, V, StepFnsT> where
StepFnsT: Unpin,
impl<K, V, StepFnsT> UnwindSafe for RangeInclusiveMap<K, V, StepFnsT> where
K: RefUnwindSafe,
StepFnsT: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more