On Thursday, 9 October 2014 at 19:26:20 UTC, Njkp wrote:
On Thursday, 9 October 2014 at 19:04:56 UTC, Anibal wrote:
Hi everyone,
I'm trying to something like a tree structure.
The following:
import std.container;
class Tree
{
private SList!Tree subTree;
}
Produces: class Tree no size yet for forward reference.
How i should proceed in order to keep this declaration?
Thanks a lot!
PD: (You guys are incredibly quick to answer, that's awesome!)
make a pointer list instead, which has a fixed size:
---
import std.container;
class Tree
{
private SList!(Tree*) subTree;
}
---
fixed size: the item as pointer. But, BTW if you put a class as
an item collection it's always a fixed size, a class is always a
ptr. Better, you 'll be able to use the pointer without
dereference.
But you prefear the solution of the other guy...It's ok. I just
hope that your subtree will not have to be reorganized too
often...because with an array, it'll be very very very slow...