Re: Converting Tree Structure from Vector



On 16 Oct 2005 12:39:53 -0700, paul.sharivker@xxxxxxxxx wrote or
quoted :

>I need to create a structure which will be loaded on JSP page and will
>have select boxes for parent->child->child->child.
>I was thinking to load the data into 4 Array List but dont know how the
>values will be related if user select a child and which child to load.
>Do you have any ideas?

You could invent a Node class that points to a parent with perhaps an
ArrayList of children. It would also have an id field and a name
field.

Put them in a HashMap indexed by id.

Then loop through i .. n looking at your Vector triples and doing the
obvious things to hook up parents and children.

After the tree is built, you might consider replacing each ArrayList
with an array.

To display the tree graphically, look into JTree.


--
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
.



Relevant Pages

  • Re: Binding sources question in Vs2005
    ... >happens is that the fill statements for the child tables get executed first ... Even if the child table is loaded after the parent it will still load all ... child rows that are potentially never seen are taking up memory. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Binding sources question in Vs2005
    ... >>dragging the parent table and then the child tables and grandchild tables, ... > Even if the child table is loaded after the parent it will still load all ... child rows that are potentially never seen are taking up memory. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: The "disappearing" subform
    ... There is data in both the parent & child forms on the load. ... do you have the master child link set between the mainform and subform? ...
    (microsoft.public.access.forms)
  • Re: One to many relationship in OOP
    ... Should i have a property called Object1.ChildObject, which would load ... the data of the child object? ... we might have a class called Parent which has a Child ... we pass in a bool to indicate if we want the child object retrieved ...
    (microsoft.public.dotnet.general)
  • Converting Tree Structure from Vector
    ... I have 3 Vectors representing a tree structure. ... I need to create a structure which will be loaded on JSP page and will ... I was thinking to load the data into 4 Array List but dont know how the ... values will be related if user select a child and which child to load. ...
    (comp.lang.java.help)