예제 #1
0
        private static int CompareIntervalsForSort(
            IntervalInt32 lhs
            , IntervalInt32 rhs
            )
        {
            var diff = lhs.min_ - rhs.min_;

            return(diff == 0 ? (lhs.Equals(rhs) ? 0 : -1) : diff);
        }
예제 #2
0
        public        IntervalInt32[] Split(
            IntervalInt32 pivot
            )
        {
            if (!Contains(pivot))
            {
                throw new ArgumentException();
            }

            return(new IntervalInt32[] {
                new IntervalInt32(min_, pivot.max_)
                , new IntervalInt32(pivot.min_, max_)
            });
        }
예제 #3
0
        public bool IntersectsWith(
            IntervalInt32 rhs
            )
        {
            var result = false;

            if (min_ < rhs.min_)
            {
                result = min_ <= rhs.max_ && max_ >= rhs.min_;
            }
            else
            {
                result = rhs.min_ <= max_ && rhs.max_ >= min_;
            }

            return(result);
        }
예제 #4
0
        public bool Contains(
            IntervalInt32 rhs
            )
        {
            var result = false;

            if (Length >= rhs.Length)
            {
                result = Contains(rhs.min_) &&
                         Contains(rhs.max_)
                ;
            }
            else
            {
                result = rhs.Contains(min_) &&
                         rhs.Contains(max_)
                ;
            }

            return(result);
        }