private static IEnumerable <Gap> findGaps(ISortedEnumerable <int> filledPositionIndices, Interval toFill) { int previousPresentIndex = toFill.Start - 1; foreach (int presentIndex in filledPositionIndices.ConcatIfNotLastElement(toFill.End)) { if (presentIndex != previousPresentIndex + 1) { yield return(new Gap(previousPresentIndex + 1, presentIndex)); } previousPresentIndex = presentIndex; } }