IntervalTree

Struct IntervalTree 

Source
pub struct IntervalTree<T, V> { /* private fields */ }
Expand description

An immutable interval tree optimized for overlap queries.

The tree is constructed via IntervalTreeBuilder and is immutable after construction, making it Send + Sync by default.

§Data Layout

Data is laid out contiguously per node for SIMD-friendly scanning:

  • Each node’s intervals are stored contiguously in starts, ends, values
  • Within a node, intervals are sorted by start (ascending)
  • by_end_indices provides descending-by-end ordering via indirection

Implementations§

Source§

impl<T, V> IntervalTree<T, V>

Source

pub fn builder() -> IntervalTreeBuilder<T, V>

Creates a new builder for constructing an interval tree.

Source

pub fn len(&self) -> usize

Returns the number of intervals in the tree.

Source

pub fn is_empty(&self) -> bool

Returns true if the tree is empty.

Source

pub fn node_count(&self) -> usize

Returns the number of nodes in the tree.

Source§

impl<T: Ord + Copy, V> IntervalTree<T, V>

Source

pub fn query<R: Into<Interval<T>>>(&self, range: R) -> QueryIter<'_, T, V>

Queries for all intervals overlapping the given range.

Returns an iterator that yields entries without allocation.

Source

pub fn query_with<R, F, B>(&self, range: R, callback: F) -> ControlFlow<B>
where R: Into<Interval<T>>, F: FnMut(&Interval<T>, &V) -> ControlFlow<B>,

Queries with a callback for early termination.

The callback receives each overlapping interval and can return ControlFlow::Break(result) to stop iteration early.

Source§

impl<V> IntervalTree<i64, V>

Source

pub fn query_simd<R, F, B>(&self, range: R, callback: F) -> ControlFlow<B>
where R: Into<Interval<i64>>, F: FnMut(&Interval<i64>, &V) -> ControlFlow<B>,

Queries with SIMD acceleration for i64 intervals.

Trait Implementations§

Source§

impl<T: Clone, V: Clone> Clone for IntervalTree<T, V>

Source§

fn clone(&self) -> IntervalTree<T, V>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug, V: Debug> Debug for IntervalTree<T, V>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Send, V: Send> Send for IntervalTree<T, V>

Source§

impl<T: Sync, V: Sync> Sync for IntervalTree<T, V>

Auto Trait Implementations§

§

impl<T, V> Freeze for IntervalTree<T, V>

§

impl<T, V> RefUnwindSafe for IntervalTree<T, V>

§

impl<T, V> Unpin for IntervalTree<T, V>
where T: Unpin, V: Unpin,

§

impl<T, V> UnwindSafe for IntervalTree<T, V>
where T: UnwindSafe, V: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.