Esempio n. 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));
    }
Esempio n. 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));
    }
Esempio n. 3
0
 public bool Equals(IntervalWithEnd <T> other)
 {
     return(other.min.Equals(min) && other.max.Equals(max));
 }
Esempio n. 4
0
 public int CompareTo(IntervalWithEnd <T> other)
 {
     return(min.CompareTo(other.min));
 }
Esempio n. 5
0
 public bool Subset(IntervalWithEnd <T> other)
 {
     return(this.min.CompareTo(other.min) <= 0 && other.max.CompareTo(this.max) <= 0);
 }
Esempio n. 6
0
 public bool Overlap(IntervalWithEnd <T> other)
 {
     return(!((max.CompareTo(other.min) < 0) || (other.max.CompareTo(min) < 0)));
 }