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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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