/// <summary> /// Execute all pending operations. /// </summary> public void FlushPendingOperations() { foreach (IntervalCollection <int, Func <TObject, TObject> > .IntervalValues pending in _pendingOperations) { // Execute operations on entire range. IList <Func <TObject, TObject> > operations = pending.Values; pending.Interval.EveryStepOf(1, i => ExecuteOperations(operations, i)); } _pendingOperations.Clear(); }
public void Intersections() { var now = DateTime.UtcNow; var intervals = new IntervalCollection(); intervals.Add(new Interval(now, TimeSpan.FromHours(1))); intervals.Add(new Interval(now.AddDays(10), TimeSpan.FromHours(1))); Assert.IsTrue(intervals.GetIntersections().Count() == 0); intervals.Clear(); intervals.Add(new Interval(now, TimeSpan.FromHours(2))); intervals.Add(new Interval(now.AddHours(-0.5), TimeSpan.FromHours(1))); var intersection = intervals.GetIntersections().Single(); Assert.AreEqual(now, intersection.Start); Assert.AreEqual(TimeSpan.FromHours(0.5), intersection.Length); }