You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// StopTraversal is used as a return value from [VisitFunc] to indicate that the iteration is to be stopped.
483
+
// It is not returned as an error by any function.
484
+
varStopTraversal=errors.New("stop tree traversal")
485
+
486
+
// VisitFunc is called on all values. Returning non-nil error will stop iteration.
487
+
// If the returned error is [StopTraversal], the iteration is interrupted, but no error is returned to the caller.
488
+
typeVisitFunc[V, Tany] func(V, T) error
489
+
490
+
// InOrderTraverse traverses the tree in order and applies VisitFunc to each node. It's safe for concurrent use. To prevent deadlock, avoid calling other tree methods within visitFunc.
// Do not percolate StopTraversal error to the caller.
518
+
iferrors.Is(err, StopTraversal) {
519
+
returnnil
520
+
}
521
+
returnerr
522
+
}
523
+
524
+
// InOrderTraverse traverses the tree in order and applies VisitFunc to each node. It's safe for concurrent use. To prevent deadlock, avoid calling other tree methods within visitFunc.
0 commit comments