GithubHelp home page GithubHelp logo

im_interval_tree's People

Contributors

jgblight avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

im_interval_tree's Issues

Can we remove the Rc for the Bound<T> in Interval?

The bounds for T in Interval are Ord + Clone, and Bound<T> is Clone if T: Clone.

I'm wondering why did you wrap with Rc. Did you need to use a type T that it is very expensive to clone? If not, which is what I would expect, is there any chance that we could remove it? Even when T would be expensive to clone, I believe the user could use an Rc/Arc her/himself without the library forcing any specific shared reference. WDYT?

Thank you very much in advance for your clarifications ;-)

Support for Arc

Hi, I need to use this data structure in a multi-thread context, which requires using Arc instead of Rc so it is Send.

I was thinking that it would be possible to support both cases using a feature. By default it would use Rc, but when the feature was specified it would use an Arc.

I'm willing to contribute it myself, I would just need some guidance from you to choose a proper name for the feature and review the PR.

Looking forward from hearing from you ;-)

Support for generic data

Hi, I found this library very useful for my use case. I need to use it to store musical notes, where every note has a start and a duration, then I can query all the notes in a certain interval. But a note has several other properties a part from the interval bounds, such as the key or the velocity, that I would like also to be stored and retrieved.

There are different approaches available:

  1. Add an optional field to the existing Interval type that stores arbitrary data associated to that interval. It would require a new generic type D that could have the type () assigned by default.
  2. Add a new type parameter D to the IntervalTree to specify the type of the data. Any type used for D should implement the trait ToInterval that would provide an Interval. By default it could use the existing Interval type as D (so we don't break backward compatibility), but people could also create their custom ones, like in my example a Note type.

I'm more inclined to use the approach number 2, but would like to have your feedback. In the meantime, I have prepared a proof of concept that runs the tests untouched (which demonstrates that it keeps backward compatibility for existing code). See this branch.

I can implement this myself, and would only require your help for feedback and review.

Interval comparison

Thanks for sharing this! I used this library as the basis for implementing an immutable interval tree in OCaml: dgllghr/interval-map.

I noticed that interval comparison treats an exclusive lower bounds as being less than inclusive lower bounds when the magnitude of the bound is equal. It also treats exclusive upper bounds as being greater than inclusive upper bounds when the magnitude of the bound is equal.

This was counter-intuitive for me. I would have expected the opposite in those situations (e.g. an inclusive lower bound is less than an exclusive lower bound when the magnitude of the bound is equal). If this is intended behavior, I'm interested to understand so I don't implement something incorrectly in my library. If it's not intended, I can put out a PR to change the behavior in this library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.