Skip to main content

Module index_based

Module index_based 

Source
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§

IndexRef
A reference that supports two-phase cloning.
PerformIndexCloningNode
Perform node - created from PrepareNode for each clone operation.
PrepareIndexCloningNode
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.