> That solution would work fine, of course.  The alternative is a
> `linked tree' structure.  Binary trees are easy (just store each
> node's left and right children, and probably the parent).  Trees
> with arbitrary numbers of branches are a little more complex.  My
> preferred solution is for each node to store parent, first child,
> and `sibling', so to enumerate a node's children, you find the
> first child then follow it's sibling list.
>

I think that this is the best thing to do for generic trees.
And if you want some shortcut access, you could create a HashTable with some
id-key you could easily generate (eg : binary trees: key could be 0-0-1-0-1
for a  node in depth 6, left left right left right)

>
> Unfortunately there isn't a standard tree class in the API, but you could
> implement a class for a tree of arbitrary objects and use that if you
> wanted.
>

I think that tere is something called jgl that includes functionality like
this (haven't used it, thus I can't be sure). Check out :
http://www.objectspace.com/products/jgl/

Dimitris

Reply via email to