-
-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Labels
Description
First of all, awesome work guys, very useful and helpful.
Just a comment about semantics if I may.
Your generic "Visitor" is more like an "Iterator".
The "Visitor" pattern usually doesn't decide how to traverse the tree, that's what an Iterator does.
Yes, your visitors also define an output, but you might wanna separate the two concerns: turn the PreOrder and PostOrder visitors into iterators.
The iterator returns the nodes one by one, and then you can pass them to a visitor that does something on them.
That way you'd decouple the traverse algorithm from whatever operation/processing the visitor wants to do.
Makes sense?