Reputation: 571
I am writing some code that needs to work with numeric ranges. I am using Google Guava library; I need some basic operations, like union and intersection.
Looking at Google Guava Documentation, intersection between ranges can be easily made with range.intersection(range) method, but I can't find any union method; the only viable option seems using RangeSet class, but it will bring even more issues: for example, it's not very intuitive to scroll every range in RangeSet...
Is there any way to merge set using Google Guava or other libraries?
It would be ok even to change library, if there are any better/more intuitive option.
Upvotes: 0
Views: 1151
Reputation: 198014
span
will take the union of two ranges that touch each other.
In any other case, you will have to use RangeSet
, though it's not very clear to me what's so unintuitive about it.
Upvotes: 1