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

Overview

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;
}
You might also like...
Aws-sdk-rust - AWS SDK for the Rust Programming Language

The AWS SDK for Rust This repo contains the new AWS SDK for Rust (the SDK) and its public roadmap. Please Note: The SDK is currently released as a dev

Rust + Yew + Axum + Tauri, full-stack Rust development for Desktop apps.

rust-yew-axum-tauri-desktop template Rust + Yew + Axum + Tauri, full-stack Rust development for Desktop apps. Crates frontend: Yew frontend app for de

A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator
A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

tmux-thumbs A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints. Usage Press ( prefix + Space

A command-line tool collection to assist development written in RUST

dtool dtool is a command-line tool collection to assist development Table of Contents Description Usage Tips Installation Description Now dtool suppor

Rust mid-level IR Abstract Interpreter

MIRAI MIRAI is an abstract interpreter for the Rust compiler's mid-level intermediate representation (MIR). It is intended to become a widely used sta

Migrate C code to Rust
Migrate C code to Rust

C2Rust helps you migrate C99-compliant code to Rust. The translator (or transpiler) produces unsafe Rust code that closely mirrors the input C code. T

C to Rust translator

Corrode: Automatic semantics-preserving translation from C to Rust This program reads a C source file and prints an equivalent module in Rust syntax.

Astronomical algorithms in Rust

astro-rust Contents API Docs About Usage Contributing References About astro-rust is a library of advanced astronomical algorithms for the Rust progra

A Rust library for calculating sun positions

sun A rust port of the JS library suncalc. Install Add the following to your Cargo.toml [dependencies] sun = "0.2" Usage pub fn main() { let unixti

Comments
  • add second lifetime for value decoupled from key when querying for `Interval`s

    add second lifetime for value decoupled from key when querying for `Interval`s

    Because the Interval to query provided to query() and query_mut() share the same lifetime with value type V ('a), it is currently not possible, for example, to construct an Interval in a function, feed it into query() and return the resulting IntervalTreeIterator from the function, e.g. this is not possible:

    fn foo(tree: &IntervalTree<int, ()>) -> impl Iterator<Item = ()> {
        let i = Interval::new(Bound::Included(21), Bound::Excluded(42));
        
        tree.query(&i)
    }
    
    ...
    
    let tree = IntervalTree<int, ()>::new()
    ...
    let values: Vec<_> = foo(&tree).collect();
    

    because i has to live just as long as the values collected to values (which it cannot).

    By replacing the single lifetime 'a with two lifetimes, 'v for the values and 'i for the interval queried, one could circumvent this problem.

    Cheers

    opened by reedts 1
Owner
Andrea Fioraldi
PhD student @ S3 EURECOM. Writing fuzzers to find assertion errors and null ptr derefs. Trying to do a Kamehameha since I was 4.
Andrea Fioraldi
The rust implementation of IPLD schemas and some associated functionalities.

Linked Data IPLD schemas and what to do with them. Beacon Directory of user content and metadata. Since this object should not change it can be used a

Defluencer 3 Mar 4, 2022
A lending iterator trait based on generic associated types and higher-rank trait bounds

A lending iterator trait based on higher-rank trait bounds (HRTBs) A lending iterator is an iterator which lends mutable borrows to the items it retur

Sebastiano Vigna 6 Oct 23, 2023
This plugin provides an interface for storing unencrypted values on the application cache folder.

Tauri Plugin Store This plugin provides an interface for storing unencrypted values on the application cache folder. Architecture This repo shape migh

Tauri 128 Jan 1, 2023
Automatically build a Rust module tree from the project directory structure

Hypermod An even lazier version of automod and supermod. Searches the src/ directory recursively for .rs files, then builds a module tree using the di

null 4 Aug 3, 2022
Rust library to scan files and expand multi-file crates source code as a single tree

syn-file-expand This library allows you to load full source code of multi-file crates into a single syn::File. Features: Based on syn crate. Handling

Vitaly Shukela 11 Jul 27, 2022
Render cargo dependency tree in online

Cargo Tree Online Check out rendered page Render cargo dependency tree in online. Usage trunk serve Copy and paste the content of Cargo.lock file to

Kangwook Lee (이강욱) 2 Sep 23, 2021
File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files.

FTZZ File Tree Fuzzer allows you to create a pseudo-random directory hierarchy filled with some number of files. Installation $ cargo +nightly install

Alex Saveau 22 Dec 28, 2022
tree-sitter server for kakoune

tree-sitter.kak Warning This currently just a proof-of-concept, and isn't stable yet. A Tree-sitter server that keeps parsed ASTs in memory. This is u

Enrico Borba 8 May 4, 2023
k-mer counter in Rust using the rust-bio and rayon crates

krust is a k-mer counter written in Rust and run from the command line that will output canonical k-mers and their frequency across the records in a f

null 14 Jan 7, 2023
Experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code

Diplomat is an experimental Rust tool for generating FFI definitions allowing many other languages to call Rust code. With Diplomat, you can simply define Rust APIs to be exposed over FFI and get high-level C, C++, and JavaScript bindings automatically!

null 255 Dec 30, 2022