Trie, traced path and path copy
Bitmap and compact array along the path

🌳 HAMT Bitmap, Popcount and Path Copying Lab

The simulator visually builds a HAMT step by step as keys are inserted, showing each key's hash code being sliced into five-bit chunks, the resulting bitmap at each node lighting up the bit corresponding to the chunk value, and the compact child array growing only by the exact number of real children, with the popcount calculation highlighted live to show exactly how a bitmap position translates into an array index.

🔬 What It Demonstrates

The simulator visually builds a HAMT step by step as keys are inserted, showing each key's hash code being sliced into five-bit chunks, the resulting bitmap at each node lighting up the bit corresponding to the chunk value, and the compact child array growing only by the exact number of real children, with the popcount calculation highlighted live to show exactly how a bitmap position translates into an array index.

💡 Did You Know?

Did you know that Clojure's persistent hash map, one of the most widely used real-world HAMT implementations, can be updated thousands of times per second even when it holds millions of entries, because each update allocates only a handful of new nodes along one short path instead of copying the whole map, thanks to the same bitmap and popcount trick you are exploring here.

Made with 🟠 Blender