Exemple #1
0
        /**
         * Returns the overlap with the given span, or null if there is no overlap.
         * @param span The span to check.
         */
        public TextSpan overlap(TextSpan span)
        {
            var overlapStart = Math.Max(this._start, span._start);
            var overlapEnd   = Math.Min(this.end(), span.end());

            if (overlapStart < overlapEnd)
            {
                return(TextSpan.fromBounds(overlapStart, overlapEnd));
            }

            return(null);
        }
Exemple #2
0
        /**
         * Returns the intersection with the given span, or null if there is no intersection.
         * @param span The span to check.
         */
        public TextSpan intersection(TextSpan span)
        {
            var intersectStart = Math.Max(this._start, span._start);
            var intersectEnd   = Math.Min(this.end(), span.end());

            if (intersectStart <= intersectEnd)
            {
                return(TextSpan.fromBounds(intersectStart, intersectEnd));
            }

            return(null);
        }