For Programmers: Free Programming Magazines  


Home > Archive > PERL Modules > June 2007 > the use of removeChild() in Tree::Simple









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author the use of removeChild() in Tree::Simple
Lovingu.McDull@gmail.com

2007-06-23, 7:58 am

I am currently using Tree::Simple module.

I originally have a tree x. My task is to insert a node G into x, so
that the B node under A go under G.

My solution is: I create G first, then G->addChild(B). then disconnect
B from A, finally A->addChild(G).

x:
A
/ \
B E...
/\ |
C D F...
y:
A
/ \
G E...
| |
B F...
/\
C D
But it seems the disconnection can't be achieved by using
removeChild(), according to the specification,
"When a child is removed, it results in the shifting up of all
children after it, and the removed child is returned."
That is, if i delete B from x, the tree will look like this. It is
difficult for me to A->addChild(G) to this intermediate tree.
A
/ \ \
C D E...
|
F...

Any suggestions? //P.S. I prefer a solution in which the nodes are
relocated rather than being removed and regenerated.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com