private static void PopulatePredictions(IRun run, TimeSpan?currentTime, int segmentIndex, IList <TimeSpan?> predictions, bool useCurrentRun, TimingMethod method) { if (currentTime != null) { PopulatePrediction(predictions, currentTime + run[segmentIndex].BestSegmentTime[method], segmentIndex + 1); foreach (var segment in run[segmentIndex].SegmentHistory) { Time segmentTime; if (segmentIndex == 0 || !run[segmentIndex - 1].SegmentHistory.TryGetValue(segment.Key, out segmentTime) || segmentTime[method] != null) { var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex, segment.Key, method); PopulatePrediction(predictions, prediction.Time[method], prediction.Index); } } if (useCurrentRun) { var currentRunPrediction = SumOfSegmentsHelper.TrackCurrentRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, currentRunPrediction.Time[method], currentRunPrediction.Index); } var personalBestRunPrediction = SumOfSegmentsHelper.TrackPersonalBestRun(run, currentTime, segmentIndex, method); PopulatePrediction(predictions, personalBestRunPrediction.Time[method], personalBestRunPrediction.Index); } }
public static void Clean(IRun run, TimingMethod method, CleanUpCallback callback = null) { var predictions = new TimeSpan?[run.Count + 1]; CalculateSumOfBest(run, 0, run.Count - 1, predictions, true, false, method); int segmentIndex = 0; TimeSpan?currentTime = TimeSpan.Zero; foreach (var segment in run) { currentTime = predictions[segmentIndex]; foreach (var nullSegment in run[segmentIndex].SegmentHistory.Where(x => !x.Value[method].HasValue)) { var prediction = SumOfSegmentsHelper.TrackBranch(run, currentTime, segmentIndex + 1, nullSegment.Key, method); CheckPrediction(run, predictions, prediction.Time[method], segmentIndex - 1, prediction.Index - 1, nullSegment.Key, method, callback); } segmentIndex++; } }