コード例 #1
0
        public override bool Overlaps(Interval <int> other)
        {
            if (other == null)
            {
                return(false);
            }

            var continuousLeft  = (Lower.Inclusive && other.Upper.Inclusive) && Math.Abs(Lower.Value - other.Upper.Value) <= 1;
            var continuousRight = (Upper.Inclusive && other.Lower.Inclusive) && Math.Abs(Upper.Value - other.Lower.Value) <= 1;

            if (continuousLeft || continuousRight)
            {
                return(true);
            }

            return(Lower.IsBefore(other.Upper) && other.Lower.IsBefore(Upper));
        }
コード例 #2
0
        public virtual bool Overlaps(Interval <T> other)
        {
            if (other == null)
            {
                return(false);
            }

            var continuousLeft  = (Lower.Inclusive || other.Upper.Inclusive) && Lower.CompareTo(other.Upper) == 0;
            var continuousRight = (other.Lower.Inclusive || Upper.Inclusive) && Upper.CompareTo(other.Lower) == 0;

            if (continuousRight || continuousLeft)
            {
                return(true);
            }

            return(Lower.IsBefore(other.Upper) && other.Lower.IsBefore(Upper));
        }
コード例 #3
0
 public virtual bool Contains(T value)
 {
     return(Lower.IsBefore(value) && Upper.IsAfter(value));
 }