Kirill Grouchnikov
12/16/2022, 4:58 PMval tree = IntervalTree<Int>()
tree.add(IntegerInterval(1, 4, Interval.Bounded.CLOSED))
tree.add(IntegerInterval(6, 8, Interval.Bounded.CLOSED))
// This ends up with three intervals [0,7], [1,4], [6,8]
tree.add(IntegerInterval(0, 7, Interval.Bounded.CLOSED))
What I’m looking for is for the data structure to end up holding the “unified” interval of [0,8] after this third operation.
And the same for deletion. If I have a single [0,8] interval and I remove [2,4], it should now have two intervals - [0,2] and [4,8].Kirill Grouchnikov
12/16/2022, 5:05 PMephemient
12/16/2022, 6:05 PMephemient
12/16/2022, 6:08 PMKirill Grouchnikov
12/16/2022, 7:44 PMval ranges = mutableListOf(IntRange(1, 4), IntRange(7, 10))
ranges.addInterval(IntRange(2, 6))
println(ranges)
Kirill Grouchnikov
12/16/2022, 7:44 PM(1, 10)
rangeKirill Grouchnikov
12/16/2022, 7:45 PMval ranges = mutableListOf(IntRange(1, 5), IntRange(7, 10))
ranges.addInterval(IntRange(6, 6))
Kirill Grouchnikov
12/16/2022, 7:50 PMephemient
12/16/2022, 7:52 PMephemient
12/16/2022, 7:52 PMMichael de Kaste
12/17/2022, 7:35 AMMichael de Kaste
12/17/2022, 7:39 AM{null=nope, 1=hi, 2=bye, 4=nope}
and you can extract ranges from that.
'deletion' is supported by adding a range with the defaultValue (which can be null for convenience ofc)