pub struct RangeSet<T> { /* private fields */ }
Expand description
A set whose items are stored as (half-open) ranges bounded
inclusively below and exclusively above (start..end)
.
See RangeMap
’s documentation for more details.
Implementations§
Source§impl<T> RangeSet<T>
impl<T> RangeSet<T>
Sourcepub fn get(&self, value: &T) -> Option<&Range<T>>
pub fn get(&self, value: &T) -> Option<&Range<T>>
Returns a reference to the range covering the given key, if any.
Sourcepub fn contains(&self, value: &T) -> bool
pub fn contains(&self, value: &T) -> bool
Returns true
if any range in the set covers the specified value.
Sourcepub fn iter(&self) -> Iter<'_, T> ⓘ
pub fn iter(&self) -> Iter<'_, T> ⓘ
Gets an ordered iterator over all ranges, ordered by range.
Sourcepub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>
pub fn intersection<'a>(&'a self, other: &'a Self) -> Intersection<'a, T>
Return an iterator over the intersection of two range sets.
Sourcepub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>
pub fn union<'a>(&'a self, other: &'a Self) -> Union<'a, T>
Return an iterator over the union of two range sets.
Sourcepub fn insert(&mut self, range: Range<T>)
pub fn insert(&mut self, range: Range<T>)
Insert a range into the set.
If the inserted range either overlaps or is immediately adjacent any existing range, then the ranges will be coalesced into a single contiguous range.
§Panics
Panics if range start >= end
.
Sourcepub fn remove(&mut self, range: Range<T>)
pub fn remove(&mut self, range: Range<T>)
Removes a range from the set, if all or any of it was present.
If the range to be removed partially overlaps any ranges in the set, then those ranges will be contracted to no longer cover the removed range.
§Panics
Panics if range start >= end
.
Sourcepub fn gaps<'a>(&'a self, outer_range: &'a Range<T>) -> Gaps<'a, T> ⓘ
pub fn gaps<'a>(&'a self, outer_range: &'a Range<T>) -> Gaps<'a, T> ⓘ
Gets an iterator over all the maximally-sized ranges
contained in outer_range
that are not covered by
any range stored in the set.
If the start and end of the outer range are the same and it does not overlap any stored range, then a single empty gap will be returned.
The iterator element type is Range<T>
.
Sourcepub fn overlapping<R: Borrow<Range<T>>>(
&self,
range: R,
) -> Overlapping<'_, T, R> ⓘ
pub fn overlapping<R: Borrow<Range<T>>>( &self, range: R, ) -> Overlapping<'_, T, R> ⓘ
Gets an iterator over all the stored ranges that are either partially or completely overlapped by the given range.
The iterator element type is &Range<T>
.
Sourcepub fn overlaps(&self, range: &Range<T>) -> bool
pub fn overlaps(&self, range: &Range<T>) -> bool
Returns true
if any range in the set completely or partially
overlaps the given range.
Trait Implementations§
Source§impl<T> Extend<Range<T>> for RangeSet<T>
impl<T> Extend<Range<T>> for RangeSet<T>
Source§fn extend<I: IntoIterator<Item = Range<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = Range<T>>>(&mut self, iter: I)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)