Exemplo n.º 1
0
        }                                                                                                 // ToString

        public virtual int CompareTo(TInterval <TFinite> other)
        {
            if (ReferenceEquals(other, null))
            {
                throw new ArgumentNullException();
            }

            return(Left.CompareTo(other.Left));
        }         // CompareTo
Exemplo n.º 2
0
        }                                               // constructor

        protected virtual TInterval <TFinite> Intersection(TInterval <TFinite> other)
        {
            if (!Intersects(other))
            {
                return(null);
            }

            return(new TInterval <TFinite>(Left.Max(other.Left), Right.Min(other.Right)));
        }         // Intersection
Exemplo n.º 3
0
        }         // 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
Exemplo n.º 4
0
        }         // constructor

        public new virtual TDisjointIntervals <TFinite> Add(TInterval <TFinite> oInterval)
        {
            if (oInterval == null)
            {
                return(this);
            }

            if (this.Any(i => i.Intersects(oInterval)))
            {
                throw new ArgumentException("Interval to add intersects with an interval in the set.");
            }

            base.Add(oInterval);

            return(this);
        }         // Add
Exemplo n.º 5
0
        }         // 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
Exemplo n.º 6
0
        }         // constructor

        public TDisjointIntervals(TInterval <TFinite> a, TInterval <TFinite> b) : this(a) {
            Add(b);
        }         // constructor
Exemplo n.º 7
0
        }                                      // constructor

        public TDisjointIntervals(TInterval <TFinite> a) : this()
        {
            Add(a);
        }         // constructor
Exemplo n.º 8
0
        }         // constructor

        protected TInterval(TInterval <TFinite> other) : this(other.Left, other.Right)
        {
        }                                                                                        // constructor
Exemplo n.º 9
0
        }         // Contains

        public virtual bool Contains(TInterval <TFinite> other)
        {
            return((Left <= other.Left) && (other.Right <= Right));
        }         // Contains
Exemplo n.º 10
0
        }         // operator -

        protected virtual DateInterval Intersection(DateInterval other)
        {
            TInterval <DateTime> oEdges = base.Intersection(other);

            return(oEdges == null ? null : new DateInterval(oEdges));
        }         // Intersection
Exemplo n.º 11
0
        }         // constructor

        protected DateInterval(TInterval <DateTime> other) : base(other.Left, other.Right)
        {
        }         // constructor