Beispiel #1
0
        public override bool Merge(IReadOnlyRange <T> other)
        {
            if (ReferenceEquals(this, other) || other.IsEmpty || Contains(other))
            {
                return(true);
            }

            if (Overlaps(other))
            {
                T min = Minimum.NotAbove(other.Minimum);
                T max = Maximum.NotBelow(other.Maximum.Maximum(min));
                if (min.IsEqual(Minimum) && max.IsEqual(Maximum))
                {
                    return(true);
                }
                Minimum = min;
                Maximum = max;
                return(true);
            }

            if (IsPreviousTo(other))
            {
                Maximum = other.Maximum;
                return(true);
            }

            if (!IsNextTo(other))
            {
                return(false);
            }
            Minimum = other.Minimum;
            return(true);
        }
Beispiel #2
0
 public Range([NotNull] IReadOnlyRange <T> range)
     : this(range.Minimum, range.Maximum)
 {
 }
Beispiel #3
0
 public NumericRange([NotNull] IReadOnlyRange <T> range)
     : base(range)
 {
 }
Beispiel #4
0
 public static LambdaRange <T> AsLambdaRange <T>([NotNull] IReadOnlyRange <T> value)
     where T : struct, IComparable
 {
     return(new LambdaRange <T>(value));
 }
 public DateRangeLister([NotNull] IReadOnlyRange <DateTime> range, DateTimeUnit unit)
     : this(range.Minimum, range.Maximum, unit)
 {
 }
Beispiel #6
0
 public static bool InRangeRx(this TimeSpan thisValue, [NotNull] IReadOnlyRange <double> range, TimeUnit unit)
 {
     return(thisValue.InRangeRx(range.Minimum, range.Maximum, unit));
 }
Beispiel #7
0
 /// <inheritdoc />
 /// <summary>
 /// Constructs a new inclusive range using the default comparer
 /// </summary>
 public LambdaRange([NotNull] IReadOnlyRange <T> range)
     : this(range.Minimum, range.Maximum, Comparer <T> .Default, true, true)
 {
 }
Beispiel #8
0
 /// <inheritdoc />
 public bool Equals(IReadOnlyRange <T> other)
 {
     return(_range.Equals(other));
 }
Beispiel #9
0
 /// <inheritdoc />
 public int CompareTo(IReadOnlyRange <T> other)
 {
     return(RangeComparer <T> .Default.Compare(_range, other));
 }
Beispiel #10
0
 public ReadOnlyRange([NotNull] IRange <T> range)
 {
     _range      = range;
     _collection = _range as ICollection ?? throw new ArgumentException("Argument does not implement ICollection.", nameof(range));
 }
Beispiel #11
0
 /// <inheritdoc />
 public bool IsNextTo(IReadOnlyRange <T> other)
 {
     return(_range.IsNextTo(other));
 }
Beispiel #12
0
 /// <inheritdoc />
 public bool IsPreviousTo(IReadOnlyRange <T> other)
 {
     return(_range.IsPreviousTo(other));
 }
Beispiel #13
0
 /// <inheritdoc />
 public bool Overlaps(IReadOnlyRange <T> other)
 {
     return(_range.Overlaps(other));
 }
Beispiel #14
0
 /// <inheritdoc />
 public bool Contains(IReadOnlyRange <T> other)
 {
     return(_range.Contains(other));
 }