public void Intersect() { CheckIntersect(Range.Full <int>(), Range.Full <int>(), Range.Full <int>()); CheckIntersect(Range.Full <int>(), Range.Empty <int>(), Range.Empty <int>()); CheckIntersect(Range.Full <int>(), Range.StartsWith(10), Range.StartsWith(10)); CheckIntersect(Range.Empty <int>(), Range.Empty <int>(), Range.Empty <int>()); CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 10, true, true), Range.Create(0, 10, true)); CheckIntersect(Range.EndsWith(10, false), Range.Create(0, 10, true, true), Range.Create(0, 10, true, false)); CheckIntersect(Range.EndsWith(10, false), Range.StartsWith(10, true)); CheckIntersect(Range.EndsWith(10, false), Range.StartsWith(10, false)); CheckIntersect(Range.EndsWith(10, true), Range.StartsWith(10, true), Range.Simple(10)); CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 9, true), Range.Create(0, 9, true)); CheckIntersect(Range.EndsWith(10, true), Range.Create(0, 9, true, false), Range.Create(0, 9, true, false)); CheckIntersect(Range.Create(0, 10, true), Range.Create(0, 2, false, false), Range.Create(0, 2, false, false)); }
/// <summary> /// Creates new range list with inverted ranges. Overlapped ranges are combined. /// </summary> /// <typeparam name="TValue">Type of range value</typeparam> /// <param name="ranges">Ranges to invert and include in new renge list.</param> /// <returns>A new range list.</returns> public static ImmutableRangeList <TValue> Invert <TValue>([CanBeNull] this IEnumerable <Range <TValue> > ranges) where TValue : IComparable <TValue> => ranges == null ? ToRangeList(Range.Full <TValue>()) : ToRangeList(ranges.SelectMany(r => r.Invert()));