Expand description
Two-phase index-based deep cloning (matching user’s approach).
Phase 1 (Prepare): Walk through all refs, build HashMap lookup and pos_array Phase 2 (Perform): Walk through again, use pos_array for O(1) lookups
This avoids HashMap lookups during the actual clone, but has overhead:
- Two passes over all data
- Cloning pos_array for each clone operation
- Pre-allocating ref_array
Structs§
- Index
Ref - A reference that supports two-phase cloning.
- Perform
Index Cloning Node - Perform node - created from PrepareNode for each clone operation.
- Prepare
Index Cloning Node - Preparation node - built once, stores the reference structure. Uses HashMap to detect shared references.
Functions§
- clone_
refs - Convenience function to clone refs using a prepare node.
- prepare_
refs - Convenience function to prepare a slice of refs.