Example #1
0
            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));
            }
Example #2
0
            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));
            }
Example #3
0
            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)));
            }
Example #4
0
 public override int CompareTo(BoundValue <T> other)
 {
     return(other.CompareWith(this));
 }
Example #5
0
 public BoundValue <T> Min(BoundValue <T> right)
 {
     return(this < right ? this : right);
 }
Example #6
0
 public BoundValue <T> Max(BoundValue <T> right)
 {
     return(this > right ? this : right);
 }
Example #7
0
 public abstract int CompareTo(BoundValue <T> other);
Example #8
0
 public override bool Includes(T value)
 {
     return(lower <= BoundValue <T> .UpperBound(value) && BoundValue <T> .LowerBound(value) <= upper);
 }
Example #9
0
 public static SingleRange ThatLessThanOrEquals(T value)
 {
     return(new SingleRange(BoundValue <T> .NegativeInfinity, BoundValue <T> .UpperBound(value)));
 }
Example #10
0
 public static SingleRange ThatGreaterThanOrEquals(T value)
 {
     return(new SingleRange(BoundValue <T> .LowerBound(value), BoundValue <T> .PositiveInfinity));
 }
Example #11
0
 private SingleRange(BoundValue <T> lower, BoundValue <T> upper)
 {
     this.lower = lower;
     this.upper = upper;
 }