public IntervalNode(IEnumerable <IIntervalable> intervals) { _point = DetermineMedian(intervals); var lefts = new List <IIntervalable>(); var rights = new List <IIntervalable>(); foreach (var inter in intervals) { if (inter.End < _point) { lefts.Add(inter); } else if (inter.Start > _point) { rights.Add(inter); } else { _intervals.Add(inter); } } if (lefts.Count > 0) { _left = new IntervalNode(lefts); } if (rights.Count > 0) { _right = new IntervalNode(rights); } }
private static List <IIntervalable> FindOverlapRange(IntervalNode node, IIntervalable interval) { if (node != null) { return(node.GetOverlap(interval)); } return(new List <IIntervalable>()); }