コード例 #1
0
        /// <summary>
        /// Check whether this range adjoins to another.
        ///
        /// Two ranges are adjoint if they are next to each other without overlapping, i.e.
        ///
        ///     [A, B) and [B, C) or
        ///     [A, B] and (B, C)
        /// </summary>
        /// <param name="other">The other range.</param>
        /// <returns>true if this range adjoins the other, false otherwise.</returns>
        public bool Adjoins(FInt32Range other)
        {
            if (IsEmpty() || other.IsEmpty())
            {
                return(false);
            }

            if (!UpperBound.IsOpen() && !other.LowerBound.IsOpen() && UpperBound.GetValue() == other.LowerBound.GetValue())
            {
                return((UpperBound.IsInclusive() && other.LowerBound.IsExclusive()) ||
                       (UpperBound.IsExclusive() && other.LowerBound.IsInclusive()));
            }

            if (!other.UpperBound.IsOpen() && !LowerBound.IsOpen() && other.UpperBound.GetValue() == LowerBound.GetValue())
            {
                return((other.UpperBound.IsInclusive() && LowerBound.IsExclusive()) ||
                       (other.UpperBound.IsExclusive() && LowerBound.IsInclusive()));
            }

            return(false);
        }