www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Representation of a tree

reply "Igor" <idemura yandex.ru> writes:
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.
Jul 04 2014
parent "safety0ff" <safety0ff.dev gmail.com> writes:
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
Jul 04 2014