https://github.com/andreafioraldi/store-interval-tree
A balanced unbounded interval-tree in Rust with associated values in the nodes
https://github.com/andreafioraldi/store-interval-tree
Last synced: 11 months ago
JSON representation
A balanced unbounded interval-tree in Rust with associated values in the nodes
- Host: GitHub
- URL: https://github.com/andreafioraldi/store-interval-tree
- Owner: andreafioraldi
- Created: 2022-10-13T12:08:51.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-22T10:21:26.000Z (over 3 years ago)
- Last Synced: 2025-06-16T01:04:26.899Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 12
- Watchers: 1
- Forks: 7
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# store-interval-tree
A balanced unbounded interval-tree in Rust with associated values in the nodes.
Based on [rudac](https://crates.io/crates/rudac) and [bio](https://crates.io/crates/bio).
## Example
```rust
use store_interval_tree::IntervalTree;
use store_interval_tree::Interval;
use std::ops::Bound::*;
let mut interval_tree = IntervalTree::::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;
}
```