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

A simple and generic implementation of an immutable interval tree.

To build it, always use FromIterator. This is not very optimized as it takes O(log n) stack (it uses recursion) but runs in O(n log n).

Implementations§

source§

impl<K: Ord, V> IntervalTree<K, V>

source

pub fn query(&self, range: Range<K>) -> QueryIter<'_, K, V>

Queries the interval tree for all elements overlapping a given interval.

This runs in O(log n + m).

source

pub fn query_point(&self, point: K) -> QueryIter<'_, K, V>

Queries the interval tree for all elements containing a given point.

This runs in O(log n + m).

source

pub fn iter(&self) -> TreeIter<'_, K, V>

Returns an iterator over all elements in the tree (in no particular order).

source

pub fn iter_sorted(&self) -> impl Iterator<Item = &Element<K, V>>

Returns an iterator over all elements in the tree, sorted by Element.range.start.

This is currently identical to IntervalTree::iter because the internal structure is already sorted this way, but may not be in the future.

Trait Implementations§

source§

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

source§

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

Returns a copy 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<K: Debug, V: Debug> Debug for IntervalTree<K, V>

source§

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

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

impl<K: Ord + Clone, V, I: Into<Element<K, V>>> FromIterator<I> for IntervalTree<K, V>

source§

fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<K: Hash, V: Hash> Hash for IntervalTree<K, V>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, K: 'a + Ord, V: 'a> IntoIterator for &'a IntervalTree<K, V>

§

type Item = &'a Element<K, V>

The type of the elements being iterated over.
§

type IntoIter = TreeIter<'a, K, V>

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

fn into_iter(self) -> TreeIter<'a, K, V>

Creates an iterator from a value. Read more
source§

impl<K, V> IntoIterator for IntervalTree<K, V>

§

type Item = Element<K, V>

The type of the elements being iterated over.
§

type IntoIter = TreeIntoIter<K, V>

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

fn into_iter(self) -> TreeIntoIter<K, V>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

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

§

impl<K, V> Send for IntervalTree<K, V>
where K: Send, V: Send,

§

impl<K, V> Sync for IntervalTree<K, V>
where K: Sync, V: Sync,

§

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

§

impl<K, V> UnwindSafe for IntervalTree<K, V>
where K: 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> 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,

§

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

§

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

§

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.