(rc *runContainer16, ac *arrayContainer)
| 2302 | } |
| 2303 | |
| 2304 | func runArrayUnionToRuns(rc *runContainer16, ac *arrayContainer) ([]interval16, uint16) { |
| 2305 | pos1 := 0 |
| 2306 | pos2 := 0 |
| 2307 | length1 := len(ac.content) |
| 2308 | length2 := len(rc.iv) |
| 2309 | target := make([]interval16, 0, len(rc.iv)) |
| 2310 | // have to find the first range |
| 2311 | // options are |
| 2312 | // 1. from array container |
| 2313 | // 2. from run container |
| 2314 | var previousInterval interval16 |
| 2315 | var cardMinusOne uint16 |
| 2316 | if ac.content[0] < rc.iv[0].start { |
| 2317 | previousInterval.start = ac.content[0] |
| 2318 | previousInterval.length = 0 |
| 2319 | pos1++ |
| 2320 | } else { |
| 2321 | previousInterval.start = rc.iv[0].start |
| 2322 | previousInterval.length = rc.iv[0].length |
| 2323 | pos2++ |
| 2324 | } |
| 2325 | |
| 2326 | for pos1 < length1 || pos2 < length2 { |
| 2327 | if pos1 < length1 { |
| 2328 | s1 := ac.content[pos1] |
| 2329 | if s1 <= previousInterval.start+previousInterval.length { |
| 2330 | pos1++ |
| 2331 | continue |
| 2332 | } |
| 2333 | if previousInterval.last() < MaxUint16 && previousInterval.last()+1 == s1 { |
| 2334 | previousInterval.length++ |
| 2335 | pos1++ |
| 2336 | continue |
| 2337 | } |
| 2338 | } |
| 2339 | if pos2 < length2 { |
| 2340 | range2 := rc.iv[pos2] |
| 2341 | if range2.start <= previousInterval.last() || range2.start > 0 && range2.start-1 == previousInterval.last() { |
| 2342 | pos2++ |
| 2343 | if previousInterval.last() < range2.last() { |
| 2344 | previousInterval.length = range2.last() - previousInterval.start |
| 2345 | } |
| 2346 | continue |
| 2347 | } |
| 2348 | } |
| 2349 | cardMinusOne += previousInterval.length + 1 |
| 2350 | target = append(target, previousInterval) |
| 2351 | if pos2 == length2 || pos1 < length1 && ac.content[pos1] < rc.iv[pos2].start { |
| 2352 | previousInterval.start = ac.content[pos1] |
| 2353 | previousInterval.length = 0 |
| 2354 | pos1++ |
| 2355 | } else { |
| 2356 | previousInterval = rc.iv[pos2] |
| 2357 | pos2++ |
| 2358 | } |
| 2359 | } |
| 2360 | cardMinusOne += previousInterval.length |
| 2361 | target = append(target, previousInterval) |
searching dependent graphs…