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