public IntervalNode(List <Interval> intervals) { leftIntervals = IntervalTree.SortByLeft(intervals, true); rightIntervals = IntervalTree.SortByLeft(intervals, false); min = leftIntervals[0].start; max = rightIntervals[rightIntervals.Count - 1].end; }
static void Main(string[] args) { Interval interval = new Interval(0, 5); Interval interval2 = new Interval(4, 6); Interval interval3 = new Interval(8, 10); List <Interval> list = new List <Interval>(); list.Add(interval); list.Add(interval2); list.Add(interval3); IntervalTree tree = new IntervalTree(list); List <Interval> ans = tree.Q(6, tree.root); for (int i = 0; i < ans.Count; i++) { Console.WriteLine("[" + ans[i].start + ";" + ans[i].end + "]"); } }