Esempio n. 1
0
 public bool Subset(NullableInterval <T> other)
 {
     return
         ((!this.min.HasValue || (other.min.HasValue && this.min.Value.CompareTo(other.min.Value) <= 0))
          &&
          (!this.max.HasValue || (other.max.HasValue && other.max.Value.CompareTo(this.max.Value) <= 0)));
 }
Esempio n. 2
0
        public NullableInterval <T> Union(NullableInterval <T> other)
        {
            T?minVal = !min.HasValue || !other.min.HasValue ? (T?)null : min.Value.CompareTo(other.min.Value) > 0 ? other.min.Value : min.Value;
            T?maxVal = !max.HasValue || !other.max.HasValue ? (T?)null : max.Value.CompareTo(other.max.Value) < 0 ? other.max.Value : max.Value;

            return(new NullableInterval <T>(minVal, maxVal));
        }
Esempio n. 3
0
 public bool Overlaps(NullableInterval <T> other)
 {
     return(!(
                (max.HasValue && other.min.HasValue && max.Value.CompareTo(other.min.Value) <= 0) ||
                (other.max.HasValue && min.HasValue && other.max.Value.CompareTo(min.Value) <= 0)
                ));
 }
Esempio n. 4
0
        public NullableInterval <T>?Intersection(NullableInterval <T> other)
        {
            T?minVal = min.HasValue && other.min.HasValue ? (min.Value.CompareTo(other.min.Value) > 0 ? min.Value : other.min.Value) : min ?? other.min;
            T?maxVal = max.HasValue && other.max.HasValue ? (max.Value.CompareTo(other.max.Value) < 0 ? max.Value : other.max.Value) : max ?? other.max;

            if (minVal.HasValue && maxVal.HasValue && minVal.Value.CompareTo(maxVal.Value) >= 0)
            {
                return(null);
            }

            return(new NullableInterval <T>(minVal, maxVal));
        }
Esempio n. 5
0
        public int CompareTo(NullableInterval <T> other)
        {
            if (min == null && other.min == null)
            {
                return(0);
            }

            var temp = min.HasValue.CompareTo(other.min.HasValue);

            if (temp != 0)
            {
                return(temp);
            }

            return(min.Value.CompareTo(other.min.Value));
        }
Esempio n. 6
0
        public int CompareTo(NullableInterval <T> other)
        {
            if (min == null && other.min == null)
            {
                return(0);
            }

            var temp = min.HasValue.CompareTo(other.min.HasValue);

            if (temp != 0)
            {
                return(temp);
            }

#pragma warning disable CS8629 // Nullable value type may be null. CSBUG
            return(min.Value.CompareTo(other.min.Value));

#pragma warning restore CS8629 // Nullable value type may be null.
        }
Esempio n. 7
0
 public bool Equals(NullableInterval <T> other)
 {
     return(other.min.Equals(min) && other.max.Equals(max));
 }