示例#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)));
 }
示例#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 }));
 }
示例#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()));
        }
示例#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)));
 }
示例#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));
 }
示例#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)));
 }
示例#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)));
 }