Tree icon indicating copy to clipboard operation
Tree copied to clipboard

Improve traverse tree

Open stdex opened this issue 5 years ago • 0 comments

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

stdex avatar Nov 21 '20 20:11 stdex