Struct intervaltree::IntervalTree
source · 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>
impl<K: Ord, V> IntervalTree<K, V>
sourcepub fn query(&self, range: Range<K>) -> QueryIter<'_, K, V> ⓘ
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)
.
sourcepub fn query_point(&self, point: K) -> QueryIter<'_, K, V> ⓘ
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)
.
sourcepub fn iter(&self) -> TreeIter<'_, K, V> ⓘ
pub fn iter(&self) -> TreeIter<'_, K, V> ⓘ
Returns an iterator over all elements in the tree (in no particular order).
sourcepub fn iter_sorted(&self) -> impl Iterator<Item = &Element<K, V>>
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>
impl<K: Clone, V: Clone> Clone for IntervalTree<K, V>
source§fn clone(&self) -> IntervalTree<K, V>
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<K: Ord + Clone, V, I: Into<Element<K, V>>> FromIterator<I> for IntervalTree<K, V>
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
fn from_iter<T: IntoIterator<Item = I>>(iter: T) -> Self
Creates a value from an iterator. Read more
source§impl<'a, K: 'a + Ord, V: 'a> IntoIterator for &'a IntervalTree<K, V>
impl<'a, K: 'a + Ord, V: 'a> IntoIterator for &'a IntervalTree<K, V>
source§impl<K, V> IntoIterator for IntervalTree<K, V>
impl<K, V> IntoIterator for IntervalTree<K, V>
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for IntervalTree<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for IntervalTree<K, V>
impl<K, V> Sync for IntervalTree<K, V>
impl<K, V> Unpin for IntervalTree<K, V>
impl<K, V> UnwindSafe for IntervalTree<K, V>where
K: UnwindSafe,
V: UnwindSafe,
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