Пример #1
0
        public override bool Merge(IReadOnlyRange <T> other)
        {
            if (ReferenceEquals(this, other) || other.IsEmpty || Contains(other))
            {
                return(true);
            }

            if (Overlaps(other))
            {
                T min = Minimum.NotAbove(other.Minimum);
                T max = Maximum.NotBelow(other.Maximum.Maximum(min));
                if (min.IsEqual(Minimum) && max.IsEqual(Maximum))
                {
                    return(true);
                }
                Minimum = min;
                Maximum = max;
                return(true);
            }

            if (IsPreviousTo(other))
            {
                Maximum = other.Maximum;
                return(true);
            }

            if (!IsNextTo(other))
            {
                return(false);
            }
            Minimum = other.Minimum;
            return(true);
        }