Exemplo n.º 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
        {
            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));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Returns a range that contains all values strictly less than <paramref name="endpoint"/>.
 /// </summary>
 public static Range <C> LessThan <C>(C endpoint) where C : IComparable
 {
     return(new Range <C>(Cut.BelowAll <C>(), Cut.BelowValue(endpoint)));
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns a range that contains all values greater than or equal to <paramref name="lower"/> and strictly
 /// less than <paramref name="upper"/>.
 /// </summary>
 /// <exception cref="ArgumentException"> if <paramref name="lower"/> is greater than <paramref name="upper"/>
 /// </exception>
 public static Range <C> ClosedOpen <C>(C lower, C upper) where C : IComparable
 {
     return(new Range <C>(Cut.BelowValue(lower), Cut.BelowValue(upper)));
 }
Exemplo n.º 4
0
 /// <summary>
 /// Returns a range that contains all values greater than or equal to <paramref name="endpoint"/>.
 /// </summary>
 public static Range <C> AtLeast <C>(C endpoint) where C : IComparable
 {
     return(new Range <C>(Cut.BelowValue(endpoint), Cut.AboveAll <C>()));
 }