Beispiel #1
0
        /// <summary>
        /// Returns a range that contains any value from <paramref name="lower"/> to <paramref name="upper"/>, where each
        /// endpoint may be either inclusive (closed) or exclusive (open).
        /// </summary>
        /// <exception cref="ArgumentException"> if <paramref name="lower"/> is greater than <paramref name="upper"/>
        /// </exception>
        public static Range <C> Bounded <C>(C lower, BoundType lowerType, C upper, BoundType upperType) where C : IComparable <C>
        {
            Cut <C> lowerBound = (lowerType == BoundType.OPEN) ? Cut.AboveValue(lower) : Cut.BelowValue(lower);
            Cut <C> upperBound = (upperType == BoundType.OPEN) ? Cut.BelowValue(upper) : Cut.AboveValue(upper);

            return(new Range <C>(lowerBound, upperBound));
        }
Beispiel #2
0
 /// <summary>
 /// Returns a range that contains all values less than or equal to <paramref name="endpoint"/>.
 /// </summary>
 public static Range <C> AtMost <C>(C endpoint) where C : IComparable <C>
 {
     return(new Range <C>(Cut.BelowAll <C>(), Cut.AboveValue(endpoint)));
 }
Beispiel #3
0
 /// <summary>
 /// Returns a range that contains all values strictly greater than <paramref name="lower"/> and less than or
 /// equal to <paramref name="upper"/>.
 /// </summary>
 /// <exception cref="ArgumentException"> if <paramref name="lower"/> is greater than <paramref name="upper"/>
 /// </exception>
 public static Range <C> OpenClosed <C>(C lower, C upper) where C : IComparable <C>
 {
     return(new Range <C>(Cut.AboveValue(lower), Cut.AboveValue(upper)));
 }
Beispiel #4
0
 /// <summary>
 /// Returns a range that contains all values strictly greater than <paramref name="endpoint"/>.
 /// </summary>
 public static Range <C> GreaterThan <C>(C endpoint) where C : IComparable <C>
 {
     return(new Range <C>(Cut.AboveValue(endpoint), Cut.AboveAll <C>()));
 }