} // 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
} // 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