Beispiel #1
0
        public static IEnumerable <Pair <MarkerRecord> > Intervals(this IEnumerable <MarkerRecord> records, int startMarker, int endMarker)
        {
            if (startMarker == endMarker)
            {
                throw new ArgumentException();
            }
            if (records == null)
            {
                yield break;
            }
            MarkerRecord start = null;

            foreach (var record in records)
            {
                if (record.Marker != startMarker && record.Marker != endMarker)
                {
                    continue;
                }
                if (record.Marker == startMarker)
                {
                    start = record;
                }
                else if (record.Marker == endMarker && start != null)
                {
                    var interval = new Pair <MarkerRecord>(start, record);
                    start = null;
                    yield return(interval);
                }
            }
        }
Beispiel #2
0
 public static bool TryParse(string line, ulong index, out MarkerRecord markerRecord) => TryParse(line, index, (marker, idx, timestamp) =>
                                                                                                  new MarkerRecord(marker, idx, timestamp), out markerRecord);