// Optimized for iterative access 2008-07-16 // Optimized with SeekCount 2008-07-18 public IEnumerable <TimedEvent> GetRange(DateTime RangeStart, DateTime RangeEnd) { // xxxx xxxx xxxx xx xx // xxxx xxxx xxxx xxxxx // ==== === === == == // Flatten ScheduleB with union // Since results are based on events in ScheduleA, A is not flatted. var IterA = _ScheduleA.GetRange(RangeStart, RangeEnd).GetSpyEnumerator(); var IterB = new UnionSchedule(_ScheduleB).GetRange(RangeStart, RangeEnd).GetSpyEnumerator(); int SeekCount = 0; while (IterA.HasMore && IterB.HasMore) { if (IterA.Peek.Intersects(IterB.Peek)) { yield return(IterA.Peek & IterB.Peek); SeekCount = 0; } else { SeekCount++; } // Iterate if (IterA.Peek.StartTime >= IterB.Peek.EndTime) { // If count threshold is met, jump iterator to next match if (SeekCount > SeekCountThreshold) { IterB = new UnionSchedule(_ScheduleB).GetRange(IterA.Peek.StartTime, RangeEnd).GetSpyEnumerator(); SeekCount = 0; } else { IterB.MoveNext(); } } else { // If count threshold is met, jump iterator to next match if (SeekCount > SeekCountThreshold) { IterA = _ScheduleA.GetRange(IterB.Peek.StartTime, RangeEnd).GetSpyEnumerator(); SeekCount = 0; } else { IterA.MoveNext(); } } } yield break; }
// Optimized for iterative access 2008-07-16 // Optimized with SeekCount 2008-07-18 public IEnumerable<TimedEvent> GetRange(DateTime RangeStart, DateTime RangeEnd) { // xxxx xxxx xxxx xx xx // xxxx xxxx xxxx xxxxx // ==== === === == == // Flatten ScheduleB with union // Since results are based on events in ScheduleA, A is not flatted. var IterA = _ScheduleA.GetRange(RangeStart, RangeEnd).GetSpyEnumerator(); var IterB = new UnionSchedule(_ScheduleB).GetRange(RangeStart, RangeEnd).GetSpyEnumerator(); int SeekCount = 0; while (IterA.HasMore && IterB.HasMore) { if (IterA.Peek.Intersects(IterB.Peek)) { yield return IterA.Peek & IterB.Peek; SeekCount = 0; } else SeekCount++; // Iterate if (IterA.Peek.StartTime >= IterB.Peek.EndTime) { // If count threshold is met, jump iterator to next match if (SeekCount > SeekCountThreshold) { IterB = new UnionSchedule(_ScheduleB).GetRange(IterA.Peek.StartTime, RangeEnd).GetSpyEnumerator(); SeekCount = 0; } else IterB.MoveNext(); } else { // If count threshold is met, jump iterator to next match if (SeekCount > SeekCountThreshold) { IterA = _ScheduleA.GetRange(IterB.Peek.StartTime, RangeEnd).GetSpyEnumerator(); SeekCount = 0; } else IterA.MoveNext(); } } yield break; }