pub struct IntervalSet<I> {
map: SmallVec<[(u32, u32); 2]>,
domain: usize,
_data: PhantomData<I>,
}
Expand description
Stores a set of intervals on the indices.
The elements in map
are sorted and non-adjacent, which means
the second value of the previous element is greater than the
first value of the following element.
Fields§
§map: SmallVec<[(u32, u32); 2]>
§domain: usize
§_data: PhantomData<I>
Implementations§
Source§impl<I: Idx> IntervalSet<I>
impl<I: Idx> IntervalSet<I>
pub fn new(domain: usize) -> IntervalSet<I>
pub fn clear(&mut self)
pub fn iter(&self) -> impl Iterator<Item = I> + '_where
I: Step,
Sourcepub fn iter_intervals(&self) -> impl Iterator<Item = Range<I>> + '_where
I: Step,
pub fn iter_intervals(&self) -> impl Iterator<Item = Range<I>> + '_where
I: Step,
Iterates through intervals stored in the set, in order.
Sourcepub fn insert(&mut self, point: I) -> bool
pub fn insert(&mut self, point: I) -> bool
Returns true if we increased the number of elements present.
Sourcepub fn insert_range(&mut self, range: impl RangeBounds<I> + Clone) -> bool
pub fn insert_range(&mut self, range: impl RangeBounds<I> + Clone) -> bool
Returns true if we increased the number of elements present.
pub fn contains(&self, needle: I) -> bool
pub fn superset(&self, other: &IntervalSet<I>) -> boolwhere
I: Step,
pub fn is_empty(&self) -> bool
Sourcepub fn first_unset_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I>
pub fn first_unset_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I>
Equivalent to range.iter().find(|i| !self.contains(i))
.
Sourcepub fn last_set_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I>
pub fn last_set_in(&self, range: impl RangeBounds<I> + Clone) -> Option<I>
Returns the maximum (last) element present in the set from range
.
pub fn insert_all(&mut self)
pub fn union(&mut self, other: &IntervalSet<I>) -> boolwhere
I: Step,
fn check_invariants(&self) -> bool
Trait Implementations§
Source§impl<I: Clone> Clone for IntervalSet<I>
impl<I: Clone> Clone for IntervalSet<I>
Source§fn clone(&self) -> IntervalSet<I>
fn clone(&self) -> IntervalSet<I>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<I> Freeze for IntervalSet<I>
impl<I> RefUnwindSafe for IntervalSet<I>where
I: RefUnwindSafe,
impl<I> Send for IntervalSet<I>where
I: Send,
impl<I> Sync for IntervalSet<I>where
I: Sync,
impl<I> Unpin for IntervalSet<I>where
I: Unpin,
impl<I> UnwindSafe for IntervalSet<I>where
I: UnwindSafe,
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§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 32 bytes