Beispiel #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 });
     }
 }
Beispiel #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);
 }
Beispiel #3
0
 /// <summary>
 /// Create a right-bounded range that contains all elements less than the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 /// <returns>A new range.</returns>
 public static FFloatRange LessThan(float value)
 {
     return(new FFloatRange(FFloatRangeBound.Open(), FFloatRangeBound.Exclusive(value)));
 }
Beispiel #4
0
 /// <summary>
 /// Create a range that excludes 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 Exclusive(float min, float max)
 {
     return(new FFloatRange(FFloatRangeBound.Exclusive(min), FFloatRangeBound.Exclusive(max)));
 }
Beispiel #5
0
 /// <summary>
 /// Return an empty range.
 /// </summary>
 /// <returns>Empty range.</returns>
 public static FFloatRange Empty()
 {
     return(new FFloatRange(FFloatRangeBound.Exclusive(default(float)), FFloatRangeBound.Exclusive(default(float))));
 }