/// <summary> /// Returns union of the interval set and the specified interval. /// </summary> public IntervalSet <A> Union(IntervalSet <A> set, Interval <A> interval) { return(Union(set, IntervalSet(interval))); }
/// <summary> /// Returns union of the two interval sets. /// </summary> public IntervalSet <A> Union(IntervalSet <A> a, IntervalSet <A> b) { return(Union(new[] { a, b })); }
/// <summary> /// Returns intersection of the two interval sets. /// </summary> public IntervalSet <A> Intersect(IntervalSet <A> a, IntervalSet <A> b) { var intersection = a.Intervals.SelectMany(x => b.Intervals.Select(y => Intersect(x, y))); return(new IntervalSet <A>(intersection.Where(i => i.NonEmpty).ToList())); }
/// <summary> /// Returns intersection of the interval set and the specified interval. /// </summary> public IntervalSet <A> Intersect(IntervalSet <A> set, Interval <A> interval) { return(Intersect(set, IntervalSet(interval))); }
/// <summary> /// Returns whether the first interval set contains the second interval set. /// </summary> public bool Contains(IntervalSet <A> a, IntervalSet <A> b) { return(Intersect(a, b).Equals(b)); }
/// <summary> /// Returns whether the interval set contains the specified interval. /// </summary> public bool Contains(IntervalSet <A> set, Interval <A> interval) { return(Contains(set, IntervalSet(interval))); }
/// <summary> /// Returns whether the interval set contains the specified value. /// </summary> public bool Contains(IntervalSet <A> set, A value) { return(Contains(set, SingleValueInterval(value))); }