the use of removeChild() in Tree::Simple

L

Lovingu.McDull

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top