Apex › Storage & databases

HAMT — the persistent map

How immutable maps (Clojure, Scala, immutable.js) make "copies" cheap. A hash array mapped trie stores entries in sparse bitmap nodes; updating a key copies only the nodes on the path to it and shares every other subtree with the old version. Insert a key and watch which nodes are copied vs reused — both versions coexist, valid and unchanged.

More in Storage & databases