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 duplicate 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> Freeze for IntervalTree<K, V>
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