Re: Specific Cloning Question
- From: "Oliver Wong" <owong@xxxxxxxxxxxxxx>
- Date: Fri, 22 Sep 2006 14:08:03 GMT
"Alex" <alexander.webb@xxxxxxxxx> wrote in message news:1158920061.757641.292170@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
3) If I am satisfied with the new tree can I not simple set the old
tree equal to the new tree?
Probably not. You can't "set" an object. You can set the value of a reference (i.e. to point to the new tree instead of the old tree), but that will not update all the other references to the old tree.
There are more time-optimal ways of doing this, but without further information, the best I can come up with is to clone the tree, apply the operation on the clone, test if it satisfies whatever you want, and if it does, re-apply the operation on the old tree. Discard the clone in either cases.
The reason I have not managed to cut down the program is that I am not
sure how to do that without losing the complexity that is causing the
problem. I have made smaller versions of things and tried cloning
things that contain lists of references but I don't seem to get the
problems in these oversimplified examples.
What's this about "lists of references"? This is the first time you mention it, AFAIK. Previously you said only that the tree has a reference to its parent, and its children. Being a binary tree, this means exactly 3 references in every node.
Anyway, if your time is too valuable there is no pressure on you or
anyone else to help or to even read this. However, I fail to see that
there is much harm in asking, just in case someone out there knows how
to help and has some time to do it.
Have you considered a recursive solution?
- Oliver
.
- Follow-Ups:
- Re: Specific Cloning Question
- From: Alex
- Re: Specific Cloning Question
- References:
- Specific Cloning Question
- From: Alex
- Re: Specific Cloning Question
- From: Thomas Weidenfeller
- Re: Specific Cloning Question
- From: Alex
- Specific Cloning Question
- Prev by Date: Re: Specific Cloning Question
- Next by Date: Re: Specific Cloning Question
- Previous by thread: Re: Specific Cloning Question
- Next by thread: Re: Specific Cloning Question
- Index(es):
Relevant Pages
|