pub struct IntervalSet { /* private fields */ }Expand description
A sorted, coalesced set of disjoint byte ranges.
Implementations§
Source§impl IntervalSet
impl IntervalSet
pub fn new() -> Self
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn ranges(&self) -> &[Range]
Sourcepub fn take_front(&mut self, n: u64) -> Option<Range>
pub fn take_front(&mut self, n: u64) -> Option<Range>
Remove and return up to n bytes from the lowest range.
Front-to-back allocation keeps the set small (usually one range) and makes sequential-write patterns friendly to the OS page cache.
Sourcepub fn insert(&mut self, r: Range)
pub fn insert(&mut self, r: Range)
Insert a range, coalescing with neighbours. Overlapping inserts are merged rather than duplicated, so re-inserting a reclaimed range that partially overlaps an existing gap is safe.
Sourcepub fn remove(&mut self, lo: u64, hi: u64)
pub fn remove(&mut self, lo: u64, hi: u64)
Remove [lo, hi) from the set, splitting ranges as needed.
Sourcepub fn invariant_holds(&self) -> bool
pub fn invariant_holds(&self) -> bool
True when every range is non-empty, sorted, and strictly disjoint from its neighbours (i.e. the coalescing invariant holds).
Trait Implementations§
Source§impl Clone for IntervalSet
impl Clone for IntervalSet
Source§fn clone(&self) -> IntervalSet
fn clone(&self) -> IntervalSet
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for IntervalSet
impl Debug for IntervalSet
Source§impl Default for IntervalSet
impl Default for IntervalSet
Source§fn default() -> IntervalSet
fn default() -> IntervalSet
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for IntervalSet
impl RefUnwindSafe for IntervalSet
impl Send for IntervalSet
impl Sync for IntervalSet
impl Unpin for IntervalSet
impl UnsafeUnpin for IntervalSet
impl UnwindSafe for IntervalSet
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