예제 #1
0
파일: Interval!1.cs 프로젝트: GFlisch/Arc4u
 /// <summary>
 /// Initializes a new instance of the <see cref="Interval&lt;T&gt;"/> 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))
 {
 }
예제 #2
0
        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;
        }
예제 #3
0
파일: Bound.cs 프로젝트: GFlisch/Arc4u
        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>));
        }
예제 #4
0
        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);
        }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Bound&lt;T&gt;"/> 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)
 {
 }
예제 #6
0
파일: Bound.cs 프로젝트: GFlisch/Arc4u
 internal static BoundDirection Reverse(BoundDirection value)
 {
     return(value == BoundDirection.Closed ? BoundDirection.Opened : BoundDirection.Closed);
 }
예제 #7
0
파일: Bound.cs 프로젝트: GFlisch/Arc4u
 internal static BoundDirection Max(BoundDirection x, BoundDirection y)
 {
     return(x < y ? y : x);
 }
예제 #8
0
파일: Bound.cs 프로젝트: GFlisch/Arc4u
 internal static BoundDirection Min(BoundDirection x, BoundDirection y)
 {
     return(x > y ? y : x);
 }