Пример #1
0
 /// <summary>
 /// Split the range into two ranges at the specified element.
 ///
 /// If a range [A, C) does not contain the element X, the original range is returned.
 /// Otherwise the range is split into two ranges [A, X) and [X, C), each of which may be empty.
 /// </summary>
 /// <param name="element">The element at which to split the range.</param>
 /// <returns></returns>
 public        FFloatRange[] Split(float element)
 {
     if (Contains(element))
     {
         return(new FFloatRange[]
         {
             new FFloatRange(LowerBound, FFloatRangeBound.Exclusive(element)),
             new FFloatRange(FFloatRangeBound.Inclusive(element), UpperBound)
         });
     }
     else
     {
         return(new FFloatRange[] { this });
     }
 }
Пример #2
0
 /// <summary>
 /// Create and initializes a new range with the given lower and upper bounds.
 ///
 /// The created range is of the form [A, B).
 /// </summary>
 /// <param name="a">The range's lower bound value (inclusive).</param>
 /// <param name="b">The range's upper bound value (exclusive).</param>
 public FFloatRange(float a, float b)
 {
     LowerBound = FFloatRangeBound.Inclusive(a);
     UpperBound = FFloatRangeBound.Exclusive(b);
 }
Пример #3
0
 /// <summary>
 /// Create a range with a single element.
 ///
 /// The created range is of the form [A, A].
 /// </summary>
 /// <param name="a">The element in the range.</param>
 public FFloatRange(float a)
 {
     LowerBound = FFloatRangeBound.Inclusive(a);
     UpperBound = FFloatRangeBound.Inclusive(a);
 }
Пример #4
0
 /// <summary>
 /// Create a range that includes the given minimum and maximum values.
 /// </summary>
 /// <param name="min">The minimum value to be included.</param>
 /// <param name="max">The maximum value to be included.</param>
 /// <returns>A new range.</returns>
 public static FFloatRange Inclusive(float min, float max)
 {
     return(new FFloatRange(FFloatRangeBound.Inclusive(min), FFloatRangeBound.Inclusive(max)));
 }
Пример #5
0
 /// <summary>
 /// Create a right-bounded range that contains all elements less than or equal to the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>A new range.</returns>
 public static FFloatRange AtMost(float value)
 {
     return(new FFloatRange(FFloatRangeBound.Open(), FFloatRangeBound.Inclusive(value)));
 }