Re: Specific Cloning Question




"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

.



Relevant Pages

  • Re: Tracking a memory leak.
    ... If you have a tree where the nodes are only referenced by the parent, ... and then the reference to the root is let go, ... and then what references they hold, and so on, and so on. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Tracking a memory leak.
    ... If you have a tree where the nodes are only referenced by the parent, ... and then the reference to the root is let go, ... Basically, the CLR performs a mark and sweep, where it starts with the ... and then what references they hold, and so on, and so on. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Tracking a memory leak.
    ... He correctly stated that the initial sweep doesn't start in the tree ... It starts on the _stack_ (and in other places mentioned by ... It then proceeds to follow all references ... IF the root of the tree is referenced by a "live" object (that has ...
    (microsoft.public.dotnet.languages.csharp)
  • performance issue with serialization ?
    ... I have an application which manages a tree of objects. ... debugger that when serializing this *a*, I go two times in GetObjectData ... GetObjectData because of object circular references? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I find all references to an object in the JVM?
    ... >>references that are reachable via the tree you walk. ... >>current framework and object model. ...
    (comp.lang.java.programmer)