intersect a span with a list, calculating the intersection span and interval range
(l List, span U64Span, expand bool)
| 61 | |
| 62 | // intersect a span with a list, calculating the intersection span and interval range |
| 63 | func (s *intersection) intersect(l List, span U64Span, expand bool) { |
| 64 | var beforeLen, afterIndex int |
| 65 | if expand { |
| 66 | beforeLen = search(l, func(test U64Span) bool { |
| 67 | return span.Start <= test.End |
| 68 | }) |
| 69 | afterIndex = search(l, func(test U64Span) bool { |
| 70 | return span.End < test.Start |
| 71 | }) |
| 72 | } else { |
| 73 | beforeLen = search(l, func(test U64Span) bool { |
| 74 | return span.Start < test.End |
| 75 | }) |
| 76 | afterIndex = search(l, func(test U64Span) bool { |
| 77 | return span.End <= test.Start |
| 78 | }) |
| 79 | } |
| 80 | if afterIndex < beforeLen { |
| 81 | afterIndex, beforeLen = beforeLen, afterIndex |
| 82 | } |
| 83 | s.lowIndex = beforeLen |
| 84 | s.highIndex = afterIndex - 1 |
| 85 | s.overlap = afterIndex - beforeLen |
| 86 | s.intersectsLow = false |
| 87 | s.intersectsHigh = false |
| 88 | if s.overlap > 0 { |
| 89 | s.low = l.GetSpan(s.lowIndex) |
| 90 | s.intersectsLow = s.low.Start < span.Start |
| 91 | s.high = l.GetSpan(s.highIndex) |
| 92 | s.intersectsHigh = span.End < s.high.End |
| 93 | } |
| 94 | } |
| 95 | |
| 96 | // merges a new span into a list, returning the index of the span |
| 97 | func merge(l MutableList, span U64Span, joinAdj bool) int { |