public bool Includes(XRange<TSource, TDistance> range) => Includes(range.actualFrom.Value) && Includes(range.actualTo.Value);
public bool Overlaps(XRange<TSource, TDistance> range) => Includes(range.actualFrom.Value) || Includes(range.actualTo.Value);
protected IEnumerable<IEnumerable<TSource>> toContiguousSequences(IEnumerable<TSource> sequence, XRange<TSource, TDistance> range) { sequence = sequence.OrderBy(x => x); var enumerator = sequence.GetEnumerator(); if (!enumerator.MoveNext()) { throw new InvalidOperationException("Sequence is empty"); } var currentList = new List<TSource> { enumerator.Current }; while (enumerator.MoveNext()) { var current = enumerator.Current; var textNextValue = range.nextValue(currentList.Last()); if (current.Equals(textNextValue)) { currentList.Add(current); } else { yield return currentList; currentList = new List<TSource> { current }; } } yield return currentList; }