Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integer set with continuous regions in Java [closed]

I would like to have int tree set implementation, which is optimized for sets with a lot of continuous regions.

For example, such tree could know that is contains entire region from 100 to 150 and hence searching for 120 ends once this region found.

Similarly, if set contains regions 500...506 and 508...600, then, once 507 is added, two regions are merged.

Similarly regions can be splitted if number removed

like image 516
Dims Avatar asked Dec 02 '25 09:12

Dims


1 Answers

I use SparseBitSet for a similar task.

Note that Guava RangeSet uses Integer not int

like image 118
sibnick Avatar answered Dec 05 '25 21:12

sibnick