public void InsertSameTreeSlightlyExpandedIntervalsIntoTree() { var tree = MergedIntervalTree.Create(ExistingIntervals); var newIntervals = new List <IInterval <uint> >(); foreach (var target in ExistingIntervals) { var interval = ClosedOpenInterval <uint> .Create(target.Start - 1, target.IsStartInclusive, target.Stop + 1, target.IsStopInclusive); tree.Add(interval); newIntervals.Add(interval); } // non-overlapping should have one more interval Assert.True(newIntervals.SequenceEqual(tree)); }
public void InsertSameTreeSlightlyExpandedIntervalsIntoTree() { var tree = MergedIntervalTree.Create(ExistingIntervals); var newIntervals = new List <IInterval <uint> >(); foreach (var target in ExistingIntervals) { var interval = ClosedOpenInterval <uint> .Create(target.Start - 1, target.IsStartInclusive, target.Stop + 1, target.IsStopInclusive); tree.Add(interval); newIntervals.Add(interval); } // non-overlapping should have one more interval MultiAssert.True(newIntervals.SequenceEqual(tree)); // subtract back the stuff we added to get leftovers. var fpTree = MergedIntervalTree.Create <uint>(); foreach (var interval in tree) { var overlaps = ExistingTree.Search(interval).ToList(); if (overlaps.Count == 0) { fpTree.Add(interval); } else { fpTree.AddRange(interval.Subtract(overlaps)); } } // double since we basically add a 1-length interval on each side. MultiAssert.Equal(ExistingIntervals.Count * 2, fpTree.Count()); MultiAssert.AssertAll(); }