/// <summary> /// Initializes a new instance of the <see cref="Interval<T>"/> class. /// </summary> /// <param name="lowerDirection">The lower direction.</param> /// <param name="lowerValue">The lower value.</param> /// <param name="upperValue">The upper value.</param> /// <param name="upperDirection">The upper direction.</param> public Interval(BoundDirection lowerDirection , T lowerValue , T upperValue , BoundDirection upperDirection) : this(new Bound <T>(BoundType.Lower, lowerDirection, lowerValue) , new Bound <T>(BoundType.Upper, upperDirection, upperValue)) { }
internal Bound(BoundType type, BoundDirection direction, T value, bool checkArguments) { if (checkArguments && Bound.IsInfinity(value) && direction == BoundDirection.Closed) { throw new ArgumentException("An infinity bound must define an opened direction."); } Type = type; Direction = direction; Value = value; }
internal static bool TryParse <T>(BoundType type , BoundDirection direction , T value , out Bound <T> result) { result = (Bound.IsInfinity(value) && direction == BoundDirection.Closed) ? default(Bound <T>) : new Bound <T>(type, direction, value); return(result != default(Bound <T>)); }
internal static bool TryParse <T>(BoundDirection lowerDirection , T lowerValue , T upperValue , BoundDirection upperDirection , out Interval <T> result) { Bound <T> lowerBound, upperBound; if (Bound.TryParse(BoundType.Lower, lowerDirection, lowerValue, out lowerBound) && Bound.TryParse(BoundType.Upper, upperDirection, upperValue, out upperBound)) { return(Interval.TryParse(lowerBound, upperBound, out result)); } result = default(Interval <T>); return(false); }
/// <summary> /// Initializes a new instance of the <see cref="Bound<T>"/> class. /// </summary> /// <param name="type">The bound type.</param> /// <param name="direction">The bound direction.</param> /// <param name="value">The bound value.</param> /// <exception cref="ArgumentException">An infinity bound must define an <see cref="P:Direction.Opened"/> direction.</exception> public Bound(BoundType type, BoundDirection direction, T value) : this(type, direction, value, true) { }
internal static BoundDirection Reverse(BoundDirection value) { return(value == BoundDirection.Closed ? BoundDirection.Opened : BoundDirection.Closed); }
internal static BoundDirection Max(BoundDirection x, BoundDirection y) { return(x < y ? y : x); }
internal static BoundDirection Min(BoundDirection x, BoundDirection y) { return(x > y ? y : x); }