Skip to content

Commit

Permalink
Merge pull request #73876 from CyrusNajmabadi/fixIntervalTree
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrusNajmabadi authored Jun 6, 2024
2 parents 09c1e6a + c0b996f commit 88c2aad
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,19 +96,20 @@ public static int FillWithIntervalsThatMatch<TIntrospector>(

while (currentNodeHasValue || stack.Count > 0)
{
// Traverse all the way down the left side of the tree, pushing nodes onto the stack as we go.
// Traverse down the left side of the tree, as long as the left node as long as it overlaps 'start' in some
// way, pushing nodes onto the stack as we go.
while (currentNodeHasValue)
{
stack.Push(currentNode!);
currentNodeHasValue = witness.TryGetLeftNode(tree, currentNode!, out currentNode);
currentNodeHasValue = ShouldExamineLeft(tree, start, currentNode!, in introspector, out currentNode);
}

Contract.ThrowIfTrue(currentNodeHasValue);
Contract.ThrowIfTrue(stack.Count == 0);
currentNode = stack.Pop();

// We only get to a node once we've walked the left side of it. So we can now process the parent node at
// that point.
// We only get to a node once we've finished walking the left side of it. So we can now process the parent
// node at that point.

var currentNodeValue = witness.GetValue(tree, currentNode);
if (testInterval(currentNodeValue, start, length, in introspector))
Expand All @@ -120,8 +121,8 @@ public static int FillWithIntervalsThatMatch<TIntrospector>(
return 1;
}

// now get the right side and set things up so we can walk into it.
currentNodeHasValue = witness.TryGetRightNode(tree, currentNode, out currentNode);
// Now traverse down the right side as long as it could overlap start/end in some way.
currentNodeHasValue = ShouldExamineRight(tree, start, end, currentNode, introspector, out currentNode);
}

return matches;
Expand Down

0 comments on commit 88c2aad

Please sign in to comment.