http://www.perlmonks.org?node_id=841386


in reply to Re: Range overlap (with a lot of ranges)
in thread Range overlap (with a lot of ranges)

So, it appears to me that to represent the ranges to be tested against, you could make an array based structure (AoA) where first element is the start number of a range and 2nd element is size or end of that range.

To query this structure, do binary search based upon start of range (wind up at same point as if you were "inserting" something into this array before the range), then look forward in the array until it is no longer possible for the sought for range to be in the current range of possible ranges (your start is > start of current 1st element in this "row". So binary search and some further number of comparisons to decide that it is no longer possible to match. This assumes that the ranges can be sorted by "start of range", which it appears that they can be.

so you will have 1 million pointers to array (AoA), each "row" has 2 elements, start and end of that range.