mergeInterval16s joins a and b into a new interval, and panics if it cannot.
(a, b interval16)
| 320 | // mergeInterval16s joins a and b into a |
| 321 | // new interval, and panics if it cannot. |
| 322 | func mergeInterval16s(a, b interval16) (res interval16) { |
| 323 | if !canMerge16(a, b) { |
| 324 | panic(fmt.Sprintf("cannot merge %#v and %#v", a, b)) |
| 325 | } |
| 326 | |
| 327 | if b.start < a.start { |
| 328 | res.start = b.start |
| 329 | } else { |
| 330 | res.start = a.start |
| 331 | } |
| 332 | |
| 333 | if b.last() > a.last() { |
| 334 | res.length = b.last() - res.start |
| 335 | } else { |
| 336 | res.length = a.last() - res.start |
| 337 | } |
| 338 | |
| 339 | return |
| 340 | } |
| 341 | |
| 342 | // intersectInterval16s returns the intersection |
| 343 | // of a and b. The isEmpty flag will be true if |
searching dependent graphs…