Beispiel #1
0
 public static Interval <V> ClosedStartClosedEnd <V>(V start, V end) where V : IComparable <V>
 {
     ValidatePointValueNotNull <V>(start);
     ValidatePointValueNotNull <V>(end);
     ValidateStartBeforeEnd(start, end);
     return(new Interval <V>(IntervalPoint <V> .Closed(start), IntervalPoint <V> .Closed(end)));
 }
Beispiel #2
0
        public bool Contains(T value)
        {
            if (this.IsEmpty())
            {
                return(false);
            }
            var other = IntervalPoint <T> .Closed(value);

            return(other >= Start && other <= End);
        }
Beispiel #3
0
        public static Interval <V> ClosedBetween <V>(Maybe <V> start, Maybe <V> end) where V : IComparable <V>
        {
            var startIntervalPoint = IntervalPoint <V> .NegativeInfinity <V>();

            var endIntervalPoint = IntervalPoint <V> .PositiveInfinity <V>();

            if (start.HasValue)
            {
                ValidatePointValueNotNull <V>(start.Value);
                startIntervalPoint = IntervalPoint <V> .Closed(start.Value);
            }
            if (end.HasValue)
            {
                ValidatePointValueNotNull <V>(end.Value);
                endIntervalPoint = IntervalPoint <V> .Closed(end.Value);
            }
            if (start.HasValue && end.HasValue)
            {
                ValidateStartBeforeEnd(start.Value, end.Value);
            }
            return(new Interval <V>(startIntervalPoint, endIntervalPoint));
        }
Beispiel #4
0
 /// <summary>
 /// Creates a degenerated interval. A degenerated interval is an interval of one single value. It is the interval representation of a point.
 /// </summary>
 /// <typeparam name="V"></typeparam>
 /// <param name="value"></param>
 /// <returns></returns>
 public static Interval <V> Degenerated <V>(V value) where V : IComparable <V>
 {
     ValidatePointValueNotNull <V>(value);
     return(new Interval <V>(IntervalPoint <V> .Closed <V>(value), IntervalPoint <V> .Closed <V>(value)));
 }
Beispiel #5
0
 public static Interval <V> InfinityStartClosedEnd <V>(V end) where V : IComparable <V>
 {
     ValidatePointValueNotNull <V>(end);
     return(new Interval <V>(IntervalPoint <V> .NegativeInfinity <V>(), IntervalPoint <V> .Closed(end)));
 }
Beispiel #6
0
 public static Interval <V> ClosedStartInfinityEnd <V>(V start) where V : IComparable <V>
 {
     ValidatePointValueNotNull <V>(start);
     return(new Interval <V>(IntervalPoint <V> .Closed(start), IntervalPoint <V> .PositiveInfinity <V>()));
 }