コード例 #1
0
ファイル: TInterval.cs プロジェクト: vijayamazon/ezbob
        }         // operator -

        public virtual bool Intersects(TInterval <TFinite> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            if (ReferenceEquals(other, null))
            {
                return(false);
            }

            return(Contains(other.Left) || Contains(other.Right) || other.Contains(this));
        }         // Intersects
コード例 #2
0
ファイル: TInterval.cs プロジェクト: vijayamazon/ezbob
        }         // Intersection

        protected virtual TDisjointIntervals <TFinite> Difference(TInterval <TFinite> other)
        {
            if (ReferenceEquals(this, other))
            {
                return(null);
            }

            if (!Intersects(other))
            {
                return(new TDisjointIntervals <TFinite>(new TInterval <TFinite>(this)));
            }

            if (other.Contains(this))
            {
                return(null);
            }

            if (Contains(other))
            {
                return(new TDisjointIntervals <TFinite>(
                           new TInterval <TFinite>(Left, other.Left.Previous()),
                           new TInterval <TFinite>(other.Right.Next(), Right)
                           ));
            }             // if

            if (Contains(other.Left))
            {
                return(new TDisjointIntervals <TFinite>(
                           new TInterval <TFinite>(Left, other.Left.Previous())
                           ));
            }             // if

            return(new TDisjointIntervals <TFinite>(
                       new TInterval <TFinite>(other.Right.Next(), Right)
                       ));
        } // Difference