[Tree-hh] Why no root node?

Kasper Peeters kasper.peeters at aei.mpg.de
Fri Nov 6 07:30:11 GMT 2009


Hi Shan,

> My question is why there is no root node? This tree class looks more
> like a forest.

Feel free to call it a forest if that helps you understand the
structure. I simply decided to have the option of more than one node
at the top, but you are free to never use that facility (i.e. just
call 'set_head' to insert a root node and then only append children to
that node, not siblings). It wasn't really a deep design issue.

> The problem I got is there is no universal way to access all nodes, because
> the nodes in the top level has no parent.

I don't understand. What's wrong with simply iterating over all nodes
from begin() to end() ? That will visit everything, including the
nodes at the top level.

Cheers,
Kasper



More information about the Tree-hh mailing list