This PR swaps implementations of TreeSet.iterate to not require a background goroutine, channel, and context. Instead we use an explicit stack and a generator function to "pull" values one at time. Unlike with the goroutine, the stack object is garbage collected automatically if we do not traverse the entire tree.
This PR swaps implementations of
TreeSet.iterate
to not require a background goroutine, channel, and context. Instead we use an explicit stack and a generator function to "pull" values one at time. Unlike with the goroutine, the stack object is garbage collected automatically if we do not traverse the entire tree.Inspiriation is from https://github.com/golang/go/discussions/56413