示例#1
0
        public IntervalWithEnd <T> Union(IntervalWithEnd <T> other)
        {
            T minVal = min.CompareTo(other.min) > 0 ? other.min : min;
            T maxVal = max.CompareTo(other.max) < 0 ? other.max : max;

            return(new IntervalWithEnd <T>(minVal, maxVal));
        }
示例#2
0
        public IntervalWithEnd <T>?Intersection(IntervalWithEnd <T> other)
        {
            T minVal = min.CompareTo(other.min) > 0 ? min : other.min;
            T maxVal = max.CompareTo(other.max) < 0 ? max : other.max;

            if (minVal.CompareTo(maxVal) > 0)
            {
                return(null);
            }

            return(new IntervalWithEnd <T>(minVal, maxVal));
        }
示例#3
0
 public bool Equals(IntervalWithEnd <T> other)
 {
     return(other.min.Equals(min) && other.max.Equals(max));
 }
示例#4
0
 public int CompareTo(IntervalWithEnd <T> other)
 {
     return(min.CompareTo(other.min));
 }
示例#5
0
 public bool Subset(IntervalWithEnd <T> other)
 {
     return(this.min.CompareTo(other.min) <= 0 && other.max.CompareTo(this.max) <= 0);
 }
示例#6
0
 public bool Overlap(IntervalWithEnd <T> other)
 {
     return(!((max.CompareTo(other.min) < 0) || (other.max.CompareTo(min) < 0)));
 }