http://qs321.pair.com?node_id=228716


in reply to Deepcopy of complex structures.

Uhm... May I propose another angle on this: don't copy the data, since copying dta is generally a Bad Thing(tm). If the data size grows, so will time. I have a gut feeling it will grow some O(n^2), but I'm not sure.

I suggest you try to just mark branches as 'off limits' for lower recursionlevels, either in the same data structure or perhaps in a similar datastructure on the side. There is a connection here to how you would implement a four-in-a-row-game (or reversi or..), marking something before taking a recursion and then removing that mark when you return. This way you don't have to alter the data in your structure, unless the rest of the algorithm needs to. Also, it might actually be easier to implement. But I would have to know more about what you are doing to say anything certain.