Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve traverse tree #81

Open
stdex opened this issue Nov 21, 2020 · 0 comments
Open

Improve traverse tree #81

stdex opened this issue Nov 21, 2020 · 0 comments

Comments

@stdex
Copy link

stdex commented Nov 21, 2020

As I can see, visitors return array of nodes, and how I should use it after I get it?
Proposed I should reiterate this array?

  1. It looks like visit method should yield value and lazy step by tree when I iterate by yield, otherwise the whole point of traversing the tree is lost (because it turns out a double tree walk).
  2. Another solution should be call visit method with callback param (anonymous function).
    E.g. in other libs:
    https://github.com/slince/tree-samples/blob/master/tests/Traversal/BFSTest.php#L17
    https://github.com/jorpo-co/tree/blob/master/tests/Traversal/BreadthFirstTraversalTest.php#L36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants