On Jan 10, 2013, at 2:28 PM, Markos Zaharioudakis <markos...@yahoo.com> wrote:
>> The problem is infinite recursion. If I ask for the size of a tree, it's the
>> sum of all the nodes. If the root node includes the size of the tree, then
>> will recurse infinitely.
> I don't understand the infinite recursion problem. What I have in mind is add
> an alloc_size() method to the XmlNode class, which will return 0 if the node
> is not a root, otherwise returm mem_sizeof(XmlTree).
If it returns 0, then you could never get the size of an XmlNode (or any class
derived from XmlNode) independently of the tree.
IMHO, you should be able to get the mem_sizeof any node (which would include
its child nodes, if any) independently of the tree. If you explicitly ask for
the mem_sizeof an XmlTree explicitly, then you'd get the size of the tree
object itself plus all the nodes.
Your team Zorba Coders is subscribed to branch lp:zorba.
Mailing list: https://launchpad.net/~zorba-coders
Post to : email@example.com
Unsubscribe : https://launchpad.net/~zorba-coders
More help : https://help.launchpad.net/ListHelp