/// <summary> /// Initializes a new interval. /// </summary> /// <param name="lower">The lower interval limit, or null if unbounded.</param> /// <param name="upper">The upper interval limit, or null if unbounded.</param> public Interval(Limit <T> lower, Limit <T> upper) { (LowerLimit = lower).Position = Position.Lower; (UpperLimit = upper).Position = Position.Upper; }
public int CompareTo(Limit <T> other) { throw new NotImplementedException(); }
public static bool LessThan <T>(this Limit <T> @this, Limit <T> other) where T : IComparable <T>, IEquatable <T> { if (@this.LowerInfinite) // assuming @this.LowerInfinite { return(other != null && other.Lower); } if (other == null) // assuming other.UpperInfinite { return(@this.Upper); } if (@this.Value.Equals(other.Value)) { if (@this.Lower) { if (@this.Closed) { // [--- // [--- false // (--- true // ---) false // ---] false return(other.Lower && other.Open); } // else @this.Open // (--- // [--- false // (--- false // ---) false // ---] false return(false); } if (@this.Upper) { if (@this.Open) { // ---) // [--- true // (--- true // ---) false // ---] true return(other.Lower || other.Closed); } // else @this.Closed // ---] // [--- false // (--- true // ---) false // ---] false return(other.Lower && other.Open); } // else @this.Position == Position.Undefined } return(@this.Value.CompareTo(other.Value) < 0); }