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