Hi, I have a question about the Interval->merge() function.
public function merge(Interval $otherInterval) { return new Interval( $this->low === null ? $otherInterval->low : min($this->low, $otherInterval->low), $this->high === null ? $otherInterval->high : max($this->high, $otherInterval->high) ); }
Consider an existing interval [1,5] and a new interval [7,9]... merging will result in a new interval [1,9]. Is this the intended behaviour? I assumed merging implied an overlap, say: [1,5] with [4,9] will result in [1,9] because 4<=5.
The reason that I ask, is because I'm looking for a specific interval tree functionality and I'm not sure if I can do this with your code. I have an interval X -> [1,10] that I need to check against an interval tree Y -> [1,4],[4,8],[7,9],[8,11].
What I want to do is Y->findCompleteOverlap(X). In the example above, this function would return 'true', because all nodes overlap the given interval X. On the other hand, if Y didn't contain interval [4,8], then it would return 'false' because there is a gap between all intervals in the tree: the intervals in Y don't completely overlap X.
Is it possible to do something like that with the existing code? I thought I could use "merge" to create one big interval and then compare it with X but that seems it won't work as intended (it will merge even when there is a gap).