findExact searches for an exact interval match.
(node *treeNode, interval ast.Interval)
| 89 | |
| 90 | // findExact searches for an exact interval match. |
| 91 | func (t *IntervalTree) findExact(node *treeNode, interval ast.Interval) bool { |
| 92 | if node == nil { |
| 93 | return false |
| 94 | } |
| 95 | |
| 96 | if node.interval.Equals(interval) { |
| 97 | return true |
| 98 | } |
| 99 | |
| 100 | start := GetStartTime(interval) |
| 101 | nodeStart := GetStartTime(node.interval) |
| 102 | |
| 103 | if start < nodeStart { |
| 104 | return t.findExact(node.left, interval) |
| 105 | } |
| 106 | // Search both subtrees for same start time |
| 107 | if t.findExact(node.right, interval) { |
| 108 | return true |
| 109 | } |
| 110 | if start == nodeStart { |
| 111 | return t.findExact(node.left, interval) |
| 112 | } |
| 113 | return false |
| 114 | } |
| 115 | |
| 116 | // QueryPoint returns all intervals containing the given timestamp. |
| 117 | func (t *IntervalTree) QueryPoint(timestamp int64, fn func(ast.Interval) error) error { |
no test coverage detected