Skip to main content

RangeTree

Struct RangeTree 

Source
pub struct RangeTree<T>
where T: RangeTreeOps,
{ /* private fields */ }
Available on crate feature avl only.

Implementations§

Source§

impl<T: RangeTreeOps> RangeTree<T>

Source

pub fn new() -> Self

Source

pub fn enable_stats(&mut self)

Source

pub fn set_ops(&mut self, ops: T)

Source

pub fn get_ops(&mut self) -> Option<&mut T>

Source

pub fn is_empty(&self) -> bool

Source

pub fn get_space(&self) -> u64

Source

pub fn get_count(&self) -> i64

Source

pub fn get_small_count(&self) -> usize

Source

pub fn get_middle_count(&self) -> usize

Source

pub fn get_large_count(&self) -> usize

Source

pub fn add_abs(&mut self, start: u64, end: u64)

Source

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

Source

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))

Source

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

Source

pub fn remove_and_split(&mut self, start: u64, size: u64) -> bool

Ensure remove all overlapping range

Returns true if removal happens

Source

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.

Source

pub fn find(&self, start: u64, size: u64) -> Option<Arc<RangeSeg>>

return only when segment overlaps with [start, start+size]

Source

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

Source

pub fn iter(&self) -> RangeTreeIter<'_, T>

Source

pub fn walk<F: FnMut(&RangeSeg)>(&self, cb: F)

Source

pub fn walk_conditioned<F: FnMut(&RangeSeg) -> bool>(&self, cb: F)

If cb returns false, break

Source

pub fn get_root(&self) -> &AvlTree<Arc<RangeSeg>, AddressTag>

Source

pub fn validate(&self)

Trait Implementations§

Source§

impl<'a, T: RangeTreeOps> IntoIterator for &'a RangeTree<T>

Source§

type Item = &'a RangeSeg

The type of the elements being iterated over.
Source§

type IntoIter = RangeTreeIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: RangeTreeOps> Send for RangeTree<T>

Auto Trait Implementations§

§

impl<T> Freeze for RangeTree<T>
where T: Freeze,

§

impl<T> !RefUnwindSafe for RangeTree<T>

§

impl<T> !Sync for RangeTree<T>

§

impl<T> Unpin for RangeTree<T>
where T: Unpin,

§

impl<T> !UnwindSafe for RangeTree<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.