Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create parent-children structure for the clones #12

Open
abdullahemad12 opened this issue Jul 22, 2018 · 1 comment
Open

Create parent-children structure for the clones #12

abdullahemad12 opened this issue Jul 22, 2018 · 1 comment

Comments

@abdullahemad12
Copy link
Owner

Task

Create a parent-children structure, so that whenever a cranbtree is cloned, its clone is attached to it. As a consquence, whenever a parent is to be deleted, all it's children will be deleted as well and their roots is set to NULL.

Design

  1. Add a parent field to the struct cranbtree that will be set to the parent if the tree is a clone. Set to NULL if the tree is not a clone.
  2. Add a list of clones to struct cranbtree that will contain a list of pointers to the clones of the parent.

Algorithm

Whenever a clone is created:

  1. set the parent field of the clone to the parent that it was cloned from
  2. Add a pointer to the clone to the list of children of the parent.

Whenever the clone is deleted:

  1. Go to the parent before the deletion and remove the pointer of this clone from the list
    note: remember destroy_objects function does not get applied to objects stored in a clone

Whenever a parent is deleted:

  1. set the root pointer of the children to NULL
  2. Destroy the children
  3. Destroy the parent
@bovem
Copy link

bovem commented Sep 9, 2018

I would like to be assigned this, if this is still unresolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants