Stacked Covered Subintervals
Function Stacked Covered Subintervals within Real Interval with keys Real Interval Stacked Covered Subintervals keysreturns an increasing array of real intervals produced by stacking u real intervals B₁ , B₂ , ... Bᵤ on the real line one on top of the other, starting with B₁ placed on the top of the stack.
The input intervals must be supplied as objects of type Real Interval
The emerging sequence of output intervals is best understood by visualizing the output intervals as opaque rods of different colors, such as that no two rods have the same color.
First the rod B1 is placed on the real line.
Then the rod B2 is placed on the real line, but in such a way that it lies underneath B1 if the two rods happen to overlap.
Similarly then, the rod B3 is placed on the real line, but in such a way that it lies underneath B1 or B2 if it happens to overlap with any of them.
The process continues until all rods have been placed on the real line.
Then, looking from above, replace all single color visible sections with a new set of rods that all differ in color and never overlap, discarding afterwards the old rods.
The final step is to stick an integer on each rod that orders them from left to right.
The rod that lies further to the left gets the number 1 and is picked as the first rod in the final output sequence of rods.
For example in the case of two intervals, if B₂ is contained in B₁, the output will consist of just one interval, the B₁.
If B₂ is not contained in B₁ but overlaps with B₁, the output will consist of two intervals, the B₁ and the part (or parts) of B₂ that does not overlap with B₁.
If B₂ is distinct from B₁₁, the output will consist of two intervals, the B₁ and B₂.
In the case of three intervals B₁ , B₂ , B₃, the output will consist of the intervals produced by stacking the first two intervals B₁ and B₂ plus any parts of B₃ that are not covered by B₁ and B₂.
Finally the produced intervals are ordered with respect to their left boundary in increasing sense.
