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
)source§impl<T> FromIterator<Range<T>> for RangeSet<T>
impl<T> FromIterator<Range<T>> for RangeSet<T>
source§impl<T> IntoIterator for RangeSet<T>
impl<T> IntoIterator for RangeSet<T>
source§impl<T: Ord> Ord for RangeSet<T>
impl<T: Ord> Ord for RangeSet<T>
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialOrd> PartialOrd for RangeSet<T>
impl<T: PartialOrd> PartialOrd for RangeSet<T>
impl<T: Eq> Eq for RangeSet<T>
impl<T> StructuralPartialEq for RangeSet<T>
Auto Trait Implementations§
impl<T> Freeze for RangeSet<T>
impl<T> RefUnwindSafe for RangeSet<T>where
T: RefUnwindSafe,
impl<T> Send for RangeSet<T>where
T: Send,
impl<T> Sync for RangeSet<T>where
T: Sync,
impl<T> Unpin for RangeSet<T>
impl<T> UnwindSafe for RangeSet<T>where
T: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)