I'm after a class that will allow me to add objects in a tree form. A bit like TreeMap but with tree walking/traversing methods.
Tree mytree = new Tree();
mytree.addRoot( rootObj );
mytree.putChild( obj1, rootObj );
mytree.putChild( obj2, rootObj );
mytree.putChild( obj3, obj1 );
Collection children = mytree.getChildren( obj1 );
//returns a collection containing just obj3
Iterator i = mytree.getTree( rootObj ).iterator();
while( i.hasNext() )
i.next() //=next in a tree walk
//in this example gives the order as
//rootObj, obj1, obj3, obj2
I'm just trying a DOM tree but it seems abit long winded for such a simple thing.
Thanks for your help,