Hi,
I am writing a program to convert the
SOAP message to a tree structure. The tree that I am going to create should be a N-Ary tree. I have created a class like the below one which is a data structure that acts as a node.Each element in the SOAP message is taken as an object.Complex elements( one object ) will maintain link to simple elements (objects)
Class nAryTree
{
String name;
String type;
String value;
nAryTree nodes[] = new nAryTree[100];
**** some functions goes on here ***
}
I have taken an array to point to simple elements in an array which is set at a size of 100. Assume a complex element movie which has name,language as the only two elements
<movie>
<name>Titanic</name>
<language>english</language>
</movie>
I am wasting lot of memory here as I created 100 objects in a class but has only two nodes.
Can somebody suggest me how can I better implement this without declaring arrays? I am interested to create my own data structure not any collections.So please suggest me how can I modify above class to manage the memory in an efficient way.
Thanks in advance,
Srinivas.