Example #1
0
 /// <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)));
 }
Example #2
0
 /// <summary>
 /// Returns union of the two interval sets.
 /// </summary>
 public IntervalSet <A> Union(IntervalSet <A> a, IntervalSet <A> b)
 {
     return(Union(new[] { a, b }));
 }
Example #3
0
        /// <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()));
        }
Example #4
0
 /// <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)));
 }
Example #5
0
 /// <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));
 }
Example #6
0
 /// <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)));
 }
Example #7
0
 /// <summary>
 /// Returns whether the interval set contains the specified value.
 /// </summary>
 public bool Contains(IntervalSet <A> set, A value)
 {
     return(Contains(set, SingleValueInterval(value)));
 }