Let\'s say you have a set of ranges:
Obviously, these range
What you describe is an example of set theory. For a general algorithm for computing unions, intersections, and differences of sets see:
www.gvu.gatech.edu/~jarek/graphics/papers/04PolygonBooleansMargalit.pdf
While the paper is targeted at graphics it is applicable to general set theory as well. Not exactly light reading material.