Data Stucture Storing Help !!
Hi,
I have structure like
level 0
level 1
-level 2
-level 2
level 1
-level 2
-level 2
level 0
level 1
-level 2
-level 2
level 1
-level 2
-level 2
I'm thinking of using a mix of ArrayList and HashMap to store the data.
Any suggestions ?
Hi,I'm in an idea that jtree is a swing class, while i'm using core java. I dont have graphics or visualizations. Can i still use jtree ? or there is an equivalent of this in core java classes ?
Isn't it just a structure like this? [root]
/\
level 0:[][]
/\/\
level 1: [] [] [] []
/\ /\ /\ /\
level 2: [][][][][][][][]
If so, you need to implement a binary tree:
class BinaryTree {
Node root;
// ... more BinaryTree attributes / methods ...
}
class Node {
Node left;
Node right;
// ... more Node attributes / methods ...
}
> Hi,
>
> Means there is no inbuilt java functionality to
> support this ?
That is correct.
> Can you give a somebody point to a code example to
> show how hierarchy is implemented ?
I already did. The Tree holds one root, which is a Node. That Node can have two children: a left- and a right child. Those children themselves can have two children of their own, etc...
You can very simple use xml:
<root>
<level0>
<level1>
<level2></level2>
<lelve2></level2>
</level1>
</level0>
</root>
And than you can use SAX or DOM model.
You can build the xml simply:
StringBuffer s=new StringBuffer(2500);
s.append("<root>").append("<level0>").append(....).....append("</root>");