Пример #1
0
        /// <summary>
        /// Compute the intersection of two ranges.
        ///
        /// The intersection of two ranges is the largest range that is contained by both ranges.
        /// </summary>
        /// <param name="x">The first range.</param>
        /// <param name="y">The second range.</param>
        /// <returns>The intersection, or an empty range if the ranges do not overlap.</returns>
        public static FInt32Range Intersection(FInt32Range x, FInt32Range y)
        {
            if (x.IsEmpty())
            {
                return(FInt32Range.Empty());
            }

            if (y.IsEmpty())
            {
                return(FInt32Range.Empty());
            }

            return(new FInt32Range(
                       FInt32RangeBound.MaxLower(x.LowerBound, y.LowerBound),
                       FInt32RangeBound.MinUpper(x.UpperBound, y.UpperBound)));
        }