Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery

Re: Deepcopy of complex structures.

by fsn (Friar)
on Jan 21, 2003 at 15:53 UTC ( #228716=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://228716]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2022-12-09 23:45 GMT
Find Nodes?
    Voting Booth?

    No recent polls found