pub struct RangeTree<T>where
T: RangeTreeOps,{ /* private fields */ }avl only.Implementations§
Source§impl<T: RangeTreeOps> RangeTree<T>
impl<T: RangeTreeOps> RangeTree<T>
pub fn new() -> Self
pub fn enable_stats(&mut self)
pub fn set_ops(&mut self, ops: T)
pub fn get_ops(&mut self) -> Option<&mut T>
pub fn is_empty(&self) -> bool
pub fn get_space(&self) -> u64
pub fn get_count(&self) -> i64
pub fn get_small_count(&self) -> usize
pub fn get_middle_count(&self) -> usize
pub fn get_large_count(&self) -> usize
pub fn add_abs(&mut self, start: u64, end: u64)
Sourcepub fn add(&mut self, start: u64, size: u64)
pub fn add(&mut self, start: u64, size: u64)
Add range segment, possible adjacent, assume no overlapping with existing range
§panic
Panic if there’s overlapping range
Sourcepub fn add_find_overlap(
&mut self,
start: u64,
size: u64,
) -> Result<(), (u64, u64)>
pub fn add_find_overlap( &mut self, start: u64, size: u64, ) -> Result<(), (u64, u64)>
Add range segment, possible adjacent, and check overlapping.
If there’s overlapping with existing range, return Err((start, end))
Sourcepub fn add_and_merge(&mut self, start: u64, size: u64)
pub fn add_and_merge(&mut self, start: u64, size: u64)
Add range which may be crossed section or larger with existing, will merge the range
Sourcepub fn remove_and_split(&mut self, start: u64, size: u64) -> bool
pub fn remove_and_split(&mut self, start: u64, size: u64) -> bool
Ensure remove all overlapping range
Returns true if removal happens
Sourcepub fn remove(&mut self, start: u64, size: u64) -> bool
pub fn remove(&mut self, start: u64, size: u64) -> bool
Only used when remove range overlap one segment,
NOTE: If not the case (start, size) might overlaps with multiple segment, use remove_and_split() instead. return true when one segment is removed.
Sourcepub fn find(&self, start: u64, size: u64) -> Option<Arc<RangeSeg>>
pub fn find(&self, start: u64, size: u64) -> Option<Arc<RangeSeg>>
return only when segment overlaps with [start, start+size]
Sourcepub fn find_contained(&self, start: u64, size: u64) -> Option<&RangeSeg>
pub fn find_contained(&self, start: u64, size: u64) -> Option<&RangeSeg>
return only when segment contains [start, size], if multiple segment exists, return the smallest start
pub fn iter(&self) -> RangeTreeIter<'_, T> ⓘ
pub fn walk<F: FnMut(&RangeSeg)>(&self, cb: F)
Sourcepub fn walk_conditioned<F: FnMut(&RangeSeg) -> bool>(&self, cb: F)
pub fn walk_conditioned<F: FnMut(&RangeSeg) -> bool>(&self, cb: F)
If cb returns false, break