foreach, an analogy
Walter Bright
newshound at digitalmars.com
Thu Oct 19 11:38:38 PDT 2006
Sean Kelly wrote:
> 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.
Yes, it's messy and complicated. A stack of pointers also means storage
allocation issues.
> C++ tree containers don't have this problem because the
> performance requirements require a balanced tree,
The iterator requirement is what's really driving the design of C++
containers. D's AAs deliver better performance than STL's trees.
> and nodes for such a
> structure contain a pointer to the parent node as well.
I know. They're also *far* more complex. Take a look at the STL source
for them. I wanted containers for D to be much easier to program.
More information about the Digitalmars-d-announce
mailing list