Representation of a tree

safety0ff via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 4 12:17:13 PDT 2014


On Friday, 4 July 2014 at 19:13:28 UTC, Igor wrote:
> Hello,
> I want to represent a tree node in D. I think if struct works 
> for it:
> struct Node {
>   Node* l, r;
> }
> But can I use pointers? Will GC treat them properly? I'm 
> leaning to think it should be okay.

Yes, in fact that's how it's done in phobos: 
https://github.com/D-Programming-Language/phobos/blob/master/std/container/dlist.d#L11


More information about the Digitalmars-d mailing list