foreach DFS/BFS for tree data-structure?

Timoses timosesu at gmail.com
Sat Jun 16 07:26:53 UTC 2018


On Thursday, 14 June 2018 at 11:31:50 UTC, Robert M. Münch wrote:
> I have a simple tree C data-structure that looks like this:
>
> node {
> 	node parent:
> 	vector[node] children;
> }
>
> I would like to create two foreach algorthims, one follwing the 
> breadth first search pattern and one the depth first search 
> pattern.
>
> Is this possible? I read about Inputranges, took a look at the 
> RBTree code etc. but don't relly know/understand where to start.

What I found really interesting when reading Ali Çehreli's book 
'Programming in D' was using fibers for tree iteration.

Check out http://ddili.org/ders/d.en/fibers.html and skip to the 
section "Fibers in range implementations"


More information about the Digitalmars-d-learn mailing list