public static SingleRange Intersect(SingleRange a, SingleRange b) { BoundValue <T> newLower = a.lower < b.lower ? b.lower : a.lower; BoundValue <T> newUpper = a.upper < b.upper ? a.upper : b.upper; return(new SingleRange(newLower, newUpper)); }
public override Range <T> GreaterThan(T value) { var newBound = BoundValue <T> .UpperBound(value); if (upper < newBound) { return(EmptyRange.Instance); } return(new SingleRange(newBound.Max(lower), upper)); }
public override Range <T> LessThanOrEquals(T value) { var newBound = BoundValue <T> .UpperBound(value); if (newBound < lower) { return(EmptyRange.Instance); } return(new SingleRange(lower, newBound.Min(upper))); }
public override int CompareTo(BoundValue <T> other) { return(other.CompareWith(this)); }
public BoundValue <T> Min(BoundValue <T> right) { return(this < right ? this : right); }
public BoundValue <T> Max(BoundValue <T> right) { return(this > right ? this : right); }
public abstract int CompareTo(BoundValue <T> other);
public override bool Includes(T value) { return(lower <= BoundValue <T> .UpperBound(value) && BoundValue <T> .LowerBound(value) <= upper); }
public static SingleRange ThatLessThanOrEquals(T value) { return(new SingleRange(BoundValue <T> .NegativeInfinity, BoundValue <T> .UpperBound(value))); }
public static SingleRange ThatGreaterThanOrEquals(T value) { return(new SingleRange(BoundValue <T> .LowerBound(value), BoundValue <T> .PositiveInfinity)); }
private SingleRange(BoundValue <T> lower, BoundValue <T> upper) { this.lower = lower; this.upper = upper; }