intersectInterval16s returns the intersection of a and b. The isEmpty flag will be true if a and b were disjoint.
(a, b interval16)
| 343 | // of a and b. The isEmpty flag will be true if |
| 344 | // a and b were disjoint. |
| 345 | func intersectInterval16s(a, b interval16) (res interval16, isEmpty bool) { |
| 346 | if !haveOverlap16(a, b) { |
| 347 | isEmpty = true |
| 348 | return |
| 349 | } |
| 350 | if b.start > a.start { |
| 351 | res.start = b.start |
| 352 | } else { |
| 353 | res.start = a.start |
| 354 | } |
| 355 | |
| 356 | bEnd := b.last() |
| 357 | aEnd := a.last() |
| 358 | var resEnd uint16 |
| 359 | |
| 360 | if bEnd < aEnd { |
| 361 | resEnd = bEnd |
| 362 | } else { |
| 363 | resEnd = aEnd |
| 364 | } |
| 365 | res.length = resEnd - res.start |
| 366 | return |
| 367 | } |
| 368 | |
| 369 | // union merges two runContainer16s, producing |
| 370 | // a new runContainer16 with the union of rc and b. |
searching dependent graphs…