#interval-tree #tree #node #algorithm #store #included

no-std store-interval-tree

A balanced unbounded interval-tree in Rust with associated values in the nodes

5 releases (3 breaking)

0.4.0 Nov 22, 2022
0.3.1 Oct 14, 2022
0.3.0 Oct 14, 2022
0.2.0 Oct 13, 2022
0.1.0 Oct 13, 2022

#2326 in Data structures

Download history 61/week @ 2024-09-11 35/week @ 2024-09-18 43/week @ 2024-09-25 41/week @ 2024-10-02 16/week @ 2024-10-09 9/week @ 2024-10-16 20/week @ 2024-10-23 25/week @ 2024-10-30 21/week @ 2024-11-06 27/week @ 2024-11-13 56/week @ 2024-11-20 79/week @ 2024-11-27 94/week @ 2024-12-04 92/week @ 2024-12-11 64/week @ 2024-12-18 5/week @ 2024-12-25

264 downloads per month

MIT/Apache

93KB
1.5K SLoC

store-interval-tree

A balanced unbounded interval-tree in Rust with associated values in the nodes.

Based on rudac and bio.

Example

use store_interval_tree::IntervalTree;
use store_interval_tree::Interval;
use std::ops::Bound::*;

let mut interval_tree = IntervalTree::<usize, bool>::new();

interval_tree.insert(Interval::new(Excluded(0), Included(1)), true);
interval_tree.insert(Interval::new(Included(0), Excluded(3)), true);
interval_tree.insert(Interval::new(Included(6), Included(10)), true);
interval_tree.insert(Interval::new(Excluded(8), Included(9)), true);
interval_tree.insert(Interval::new(Excluded(15), Excluded(23)), true);
interval_tree.insert(Interval::new(Included(16), Excluded(21)), true);
interval_tree.insert(Interval::new(Included(17), Excluded(19)), true);
interval_tree.insert(Interval::new(Excluded(19), Included(20)), true);
interval_tree.insert(Interval::new(Excluded(25), Included(30)), true);
interval_tree.insert(Interval::new(Included(26), Included(26)), true);

let interval = Interval::new(Included(8), Included(26));
let iter = interval_tree.query_mut(&interval);

for mut entry in iter {
    *entry.value() = false;
}

Dependencies

~465KB