Re: Specific Cloning Question



Alex wrote:
I realise it is hard to help without seeing the code

It is actually a waste of our time.

but I am looking
for general advice on whether cloning is a sensible way to achieve what
I want.

No, it is not.

How do I know? I don't, I am just guessing, because you haven't shown us how you do things, haven't given us important information like the size of the tree or the complexity of the operations you intend to do on the clone and you eventually want to undo.

The reason why I still say it is not a sensible way is because you have not devised (or not told us) a sensible way of what should happen if you are satisfied with the changes to the clone and you decide to keep the cloned tree. Then you might have to "magically" change references to the old tree all over your program. Might, because we don't know your program. That's manageable with another level of indirection, but without you mentioning it, and without seeing your code I simply state cloning is not a good idea in this case.


If so...how do you go about it? If you think you can help I am
happy to send you my code but it seems silly to post it all here as
it's quite big.

If you can't be bothered to invest some time to cut down your code to some useful demo of the problem, and if you can't be bothered to even copy the exception error messages verbatim, why should we invest our time to second-guess? Is your time more valuable than ours?

/Thomas


--
The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
.



Relevant Pages

  • Re: Specific Cloning Question
    ... cloned tree. ... Then you might have to "magically" change references to the ... cloning is not a good idea in this case. ... If you can't be bothered to invest some time to cut down your code to ...
    (comp.lang.java.help)
  • Re: What about cloning cattle and the FDA not informing us...
    ... Then stay very far away from any tree fruit, nuts, vine fruits, garlic, ... "cloning" that has been practiced for centuries. ... the term "clone" that is in many nursery and garden catalogs. ... Why can't I get a packet of seeds for it? ...
    (misc.health.alternative)
  • Re: Specific Cloning Question
    ... tried cloning the tree by cloning all the nodes in it. ... problem here is that when I try to clone Node A it has a reference to ... Alternatively, you could wrap all your nodes in an actual Tree object, ... public MyNode subtreeCopy{ ...
    (comp.lang.java.help)
  • Re: Specific Cloning Question
    ... tried cloning the tree by cloning all the nodes in it. ... problem here is that when I try to clone Node A it has a reference to ... it has a reference to Node A as its child it goes back to trying to ... Alternatively, you could wrap all your nodes in an actual Tree object, ...
    (comp.lang.java.help)