in reply to Re: Efficient partial deep cloning
in thread Efficient partial deep cloning

I forgot about cycles, so yes, I need to worry about those. Damn.

Cheers,
Ovid

New address of my CGI Course.

Replies are listed 'Best First'.
Re^3: Efficient partial deep cloning
by exussum0 (Vicar) on Jan 08, 2008 at 15:32 UTC
    Can't you use something like the reference of the current "thing" and the "thing" to be considered to be copied as a key in a hashset? Everytime you encounter those two things in that relationsip, process it once and only once?

    Or.. create an algorithm to do a breadth first search (can be less memory intense) to discover all edges and copy them in a graph?

      In my current implementation, I use a %seen hash which tracks those references. Very easy to implement.

      Cheers,
      Ovid

      New address of my CGI Course.