This does not represent the HAMTs algorithm. It is a toy display to show the idea of how the tree/trie would be built, sharing partial paths, and versioning.
Persistent HAMTs use path copying to maintain multiple versions efficiently:
- When a key is inserted or updated, only nodes along the affected path are copied
- Green nodes are newly created in the current version
- Yellow nodes are shared from previous versions (structural sharing)
- Each version maintains references to its unique nodes and shared nodes
- This enables efficient memory usage while allowing access to any previous version
Key Demonstration:
- Insert multiple key-value pairs to create new versions
- Switch between versions to see how each version preserves its state
- Notice how updating an existing key creates a new path while maintaining the original
- Observe which nodes are shared between versions (highlighted in yellow)