pub struct RangeSet { /* private fields */ }
Expand description
Set of ranges implemented with a BTreeMap. No overlapping ranges are allowed. Consecutive ranges are merged. Representable ranges are [0, u64::MAX).
Implementations§
Source§impl RangeSet
impl RangeSet
pub fn new(max_size: usize) -> RangeSet
pub fn unlimited() -> RangeSet
Sourcepub fn insert_range(&mut self, new_range: Range<u64>) -> bool
pub fn insert_range(&mut self, new_range: Range<u64>) -> bool
Insert a range into the set
Sourcepub fn materialize_bounds(range: impl RangeBounds<u64>) -> Range<u64>
pub fn materialize_bounds(range: impl RangeBounds<u64>) -> Range<u64>
Convert RangeBounds to ordinary range
Sourcepub fn remove_range(
&mut self,
to_remove: impl RangeBounds<u64> + Clone,
) -> usize
pub fn remove_range( &mut self, to_remove: impl RangeBounds<u64> + Clone, ) -> usize
Remove range from set
Sourcepub fn iter(&self) -> impl Iterator<Item = Range<u64>> + '_
pub fn iter(&self) -> impl Iterator<Item = Range<u64>> + '_
Iterate all ranges contained in set
Sourcepub fn iter_range(
&self,
range: impl RangeBounds<u64>,
) -> impl Iterator<Item = Range<u64>> + '_
pub fn iter_range( &self, range: impl RangeBounds<u64>, ) -> impl Iterator<Item = Range<u64>> + '_
Iterate all ranges in set intersecting provided range
Sourcepub fn range_complement(
&self,
range: Range<u64>,
) -> impl Iterator<Item = Range<u64>> + '_
pub fn range_complement( &self, range: Range<u64>, ) -> impl Iterator<Item = Range<u64>> + '_
Find all ranges within provided range but which do not exist in the set
Sourcepub fn peek_first(&self) -> Option<Range<u64>>
pub fn peek_first(&self) -> Option<Range<u64>>
Peek first value in set
Auto Trait Implementations§
impl Freeze for RangeSet
impl RefUnwindSafe for RangeSet
impl Send for RangeSet
impl Sync for RangeSet
impl Unpin for RangeSet
impl UnwindSafe for RangeSet
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
Mutably borrows from an owned value. Read more