Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntervalTree in Guava

I am working with Guava's Range class for processing intervals. I wanted to know if it is possible to find the closest interval from a set of intervals to a given point/interval by using some of the Guava's collection containers ?

I tried searching for interval trees in Java and here is what I found. I would prefer to do it by using one of the Guava classes if possible.

http://picard.sourceforge.net/javadoc/net/sf/picard/util/IntervalTree.html http://tribble.googlecode.com/svn/trunk/src/org/broad/tribble/index/interval/IntervalTree.java

Thanks

like image 648
user1998031 Avatar asked Aug 08 '26 19:08

user1998031


1 Answers

Guava doesn't provide this, though you might be able to build such a thing on top of a RangeSet by finding the first range before and after a given point.

But generally, Guava Ranges know nothing about distances, metrics, or anything except the comparison ordering of a type. They don't know that 10 is closer to 11 than 15.

like image 123
Louis Wasserman Avatar answered Aug 11 '26 09:08

Louis Wasserman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!