Skip to content

Commit 6f08675

Browse files
authored
Update index.go
1 parent 5a331a7 commit 6f08675

File tree

1 file changed

+8
-0
lines changed
  • er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof

1 file changed

+8
-0
lines changed

er-cha-sou-suo-shu-de-di-kda-jie-dian-lcof/index.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ func ReverseInOrderIterator(ctx context.Context, root *TreeNode) (gen chan int)
3737

3838
return
3939
}
40+
41+
select {
42+
case <-ctx.Done():
43+
return
44+
default:
45+
target <- v
46+
}
47+
4048
YieldAll(ctx, gen, ReverseInOrderIterator(ctx, root.Right))
4149
YieldOne(
4250
ctx, gen, root.Val)

0 commit comments

Comments
 (0)