What is the best way to deeply clone an interconnected set of objects? Example:
class A {
B theB;
}
class B {
A theA;
}
class Container {
A[] a;
B[] b;
}
The obvious thing to do is walk around the facilities and deeply clone everything that I come to him. This creates a problem, however, if I clone Awhich contains B, and what is Balso in Container, it Bwill be cloned twice after I clone Container.
The next logical step is to create Dictionaryand search for each object before I clone it. It looks like it could be a slow and indecent decision.
Any thoughts?