the use of removeChild() in Tree::Simple

Discussion in 'Perl Misc' started by Lovingu.McDull@gmail.com, Jun 23, 2007.

  1. Guest

    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.
     
    , Jun 23, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Achille
    Replies:
    1
    Views:
    2,895
    Alexey Dmitriev
    Nov 22, 2004
  2. Stub

    B tree, B+ tree and B* tree

    Stub, Nov 12, 2003, in forum: C Programming
    Replies:
    3
    Views:
    10,137
  3. emulate removechild in IE 4?

    , Dec 31, 2004, in forum: Javascript
    Replies:
    2
    Views:
    133
    Martin Honnen
    Jan 1, 2005
  4. Replies:
    1
    Views:
    116
  5. Enzo

    RemoveChild

    Enzo, Jun 30, 2005, in forum: Javascript
    Replies:
    7
    Views:
    133
    Michael Winter
    Jul 1, 2005
Loading...

Share This Page