pub struct RangeInclusiveSet<T, StepFnsT = T> { /* private fields */ }
Expand description
A set whose items are stored as ranges bounded
inclusively below and above (start..=end)
.
See RangeInclusiveMap
’s documentation for more details.
Implementations§
source§impl<T> RangeInclusiveSet<T, T>
impl<T> RangeInclusiveSet<T, T>
source§impl<T, StepFnsT> RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> RangeInclusiveSet<T, StepFnsT>
sourcepub fn new_with_step_fns() -> Self
pub fn new_with_step_fns() -> Self
Makes a new empty RangeInclusiveSet
, specifying successor and
predecessor functions defined separately from T
itself.
This is useful as a workaround for Rust’s “orphan rules”,
which prevent you from implementing StepLite
for T
if T
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.
sourcepub fn get(&self, value: &T) -> Option<&RangeInclusive<T>>
pub fn get(&self, value: &T) -> Option<&RangeInclusive<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 insert(&mut self, range: RangeInclusive<T>)
pub fn insert(&mut self, range: RangeInclusive<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: RangeInclusive<T>)
pub fn remove(&mut self, range: RangeInclusive<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 RangeInclusive<T>,
) -> Gaps<'a, T, StepFnsT> ⓘ
pub fn gaps<'a>( &'a self, outer_range: &'a RangeInclusive<T>, ) -> Gaps<'a, T, StepFnsT> ⓘ
Gets an iterator over all the maximally-sized ranges
contained in outer_range
that are not covered by
any range stored in the set.
The iterator element type is RangeInclusive<T>
.
sourcepub fn overlapping<R: Borrow<RangeInclusive<T>>>(
&self,
range: R,
) -> Overlapping<'_, T, R> ⓘ
pub fn overlapping<R: Borrow<RangeInclusive<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 RangeInclusive<T>
.
sourcepub fn overlaps(&self, range: &RangeInclusive<T>) -> bool
pub fn overlaps(&self, range: &RangeInclusive<T>) -> bool
Returns true
if any range in the set completely or partially
overlaps the given range.
sourcepub fn first(&self) -> Option<&RangeInclusive<T>>
pub fn first(&self) -> Option<&RangeInclusive<T>>
Returns the first range in the set, if one exists. The range is the minimum range in this set.
sourcepub fn last(&self) -> Option<&RangeInclusive<T>>
pub fn last(&self) -> Option<&RangeInclusive<T>>
Returns the last range in the set, if one exists. The range is the maximum range in this set.
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 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.
Trait Implementations§
source§impl<T: Clone, StepFnsT: Clone> Clone for RangeInclusiveSet<T, StepFnsT>
impl<T: Clone, StepFnsT: Clone> Clone for RangeInclusiveSet<T, StepFnsT>
source§fn clone(&self) -> RangeInclusiveSet<T, StepFnsT>
fn clone(&self) -> RangeInclusiveSet<T, StepFnsT>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T> Debug for RangeInclusiveSet<T>
impl<T> Debug for RangeInclusiveSet<T>
source§impl<T, StepFnsT> Default for RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> Default for RangeInclusiveSet<T, StepFnsT>
source§impl<T> Extend<RangeInclusive<T>> for RangeInclusiveSet<T>
impl<T> Extend<RangeInclusive<T>> for RangeInclusiveSet<T>
source§fn extend<I: IntoIterator<Item = RangeInclusive<T>>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = RangeInclusive<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: Ord + Clone + StepLite, const N: usize> From<[RangeInclusive<T>; N]> for RangeInclusiveSet<T>
impl<T: Ord + Clone + StepLite, const N: usize> From<[RangeInclusive<T>; N]> for RangeInclusiveSet<T>
source§fn from(value: [RangeInclusive<T>; N]) -> Self
fn from(value: [RangeInclusive<T>; N]) -> Self
source§impl<T> FromIterator<RangeInclusive<T>> for RangeInclusiveSet<T>
impl<T> FromIterator<RangeInclusive<T>> for RangeInclusiveSet<T>
source§fn from_iter<I: IntoIterator<Item = RangeInclusive<T>>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = RangeInclusive<T>>>(iter: I) -> Self
source§impl<T> IntoIterator for RangeInclusiveSet<T>
impl<T> IntoIterator for RangeInclusiveSet<T>
source§impl<T: Ord, StepFnsT: Ord> Ord for RangeInclusiveSet<T, StepFnsT>
impl<T: Ord, StepFnsT: Ord> Ord for RangeInclusiveSet<T, StepFnsT>
source§fn cmp(&self, other: &RangeInclusiveSet<T, StepFnsT>) -> Ordering
fn cmp(&self, other: &RangeInclusiveSet<T, StepFnsT>) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl<T: PartialEq, StepFnsT: PartialEq> PartialEq for RangeInclusiveSet<T, StepFnsT>
impl<T: PartialEq, StepFnsT: PartialEq> PartialEq for RangeInclusiveSet<T, StepFnsT>
source§fn eq(&self, other: &RangeInclusiveSet<T, StepFnsT>) -> bool
fn eq(&self, other: &RangeInclusiveSet<T, StepFnsT>) -> bool
self
and other
values to be equal, and is used by ==
.source§impl<T: PartialOrd, StepFnsT: PartialOrd> PartialOrd for RangeInclusiveSet<T, StepFnsT>
impl<T: PartialOrd, StepFnsT: PartialOrd> PartialOrd for RangeInclusiveSet<T, StepFnsT>
impl<T: Eq, StepFnsT: Eq> Eq for RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> StructuralPartialEq for RangeInclusiveSet<T, StepFnsT>
Auto Trait Implementations§
impl<T, StepFnsT> Freeze for RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> RefUnwindSafe for RangeInclusiveSet<T, StepFnsT>where
StepFnsT: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, StepFnsT> Send for RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> Sync for RangeInclusiveSet<T, StepFnsT>
impl<T, StepFnsT> Unpin for RangeInclusiveSet<T, StepFnsT>where
StepFnsT: Unpin,
impl<T, StepFnsT> UnwindSafe for RangeInclusiveSet<T, StepFnsT>where
StepFnsT: UnwindSafe,
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
)