3 ms·
Persistent data structures utilize structural sharing, meaning that the current version of the structures shares as much from its tree as possible with old vers
by raspasov 12y ago
Persistent data structures utilize structural sharing, meaning that the current version of the structures shares as much from its tree as possible with old versions. This effectively allows any thread to make a new version of the data structure efficiently and without having to use locks for reading. They are very useful in the face of concurrency and multiple reader/writer threads.
One thing to remember is that getting a new version of the data structure does not change old ones at all. In order to change state, in Clojure for example, you use constructs such as atoms to "advance" a persistent data structure forward. Think about it like advancing through your git commit history - efficiently and by only applying the delta for the next "change".