foreach, an analogy

Sean Kelly sean at f4.ca
Thu Oct 19 10:50:18 PDT 2006


Walter Bright wrote:
> 
> How do you make for work with the following data structure:
> 
>     struct Tree
>     {    Tree* left;
>         Tree* right;
>         int data;
>     }
> ?

The iterator would have to contain a stack of pointers to previously 
visited nodes.  C++ tree containers don't have this problem because the 
performance requirements require a balanced tree, and nodes for such a 
structure contain a pointer to the parent node as well.


Sean



More information about the Digitalmars-d-announce mailing list