solveRange finds the set of matching regions for the given sections of A and B. * First the longest matching region is found, then we recurse on the area before the match, * and then on the area after the match. * * @param aStart - The starting line of the left text. * @param aEnd - T
(aStart: number, aEnd: number, bStart: number, bEnd: number)
| 162 | * @returns The matching regions. |
| 163 | */ |
| 164 | solveRange(aStart: number, aEnd: number, bStart: number, bEnd: number): MatchRegion[] { |
| 165 | if (bEnd - bStart <= 1) { |
| 166 | return []; |
| 167 | } |
| 168 | if (aEnd - aStart <= 1) { |
| 169 | return []; |
| 170 | } |
| 171 | |
| 172 | const region = this.longestSubstring(aStart, aEnd, bStart, bEnd); |
| 173 | if (region == null) { |
| 174 | return []; |
| 175 | } |
| 176 | |
| 177 | return [ |
| 178 | ...this.solveRange(aStart, region.aStart, bStart, region.bStart), |
| 179 | region, |
| 180 | ...this.solveRange(region.aEnd, aEnd, region.bEnd, bEnd), |
| 181 | ]; |
| 182 | } |
| 183 | |
| 184 | findCommonLines(aa: string[], bb: string[]): MatchRegion[] { |
| 185 | const histogram = Histogram.fromLines(aa, 0, aa.length); |