using System; using System.Collections; using System.Collections.Generic; namespace Cryville.Crtr.Event { public class EventBatch : IComparable, IEnumerable { public double Time { get; private set; } readonly List queue = new(); public int Count { get { return queue.Count; } } public EventBatch(double time) { Time = time; } public StampedEvent this[int index] { get { return queue[index]; } } public void Add(StampedEvent ev) { Enqueue(ev); } public void Enqueue(StampedEvent ev) { int i = queue.BinarySearch(ev); if (i < 0) queue.Insert(~i, ev); } public int CompareTo(EventBatch other) { return Time.CompareTo(other.Time); } public IEnumerator GetEnumerator() { return queue.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } }