in reply to Re^2: An iterator for (not "iterating") a recursive data structure.
in thread An iterator for (not "iterating") a recursive data structure.
It's not duplicating the memory, just caching the current path from root to leave, very similar to my solution here
Worst case scenario with a balanced two level "tree" would mean approx @stack == 2*sqrt(@nodes) .
For 200 million elements that's about 28000 elements.
If that's still to many store a lazy iterator in the @stack returning the children of one node (like a function ref or an object or a tied array) and process it in the iterator.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
|
---|