Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Deepcopy of complex structures.

by fsn (Friar)
on Jan 21, 2003 at 15:53 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-19 21:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found