3 ms·
The most common point is that they're safe to share between threads making parallel algorithms easier to invent, understand, and implement correctly. You can a
by haroldl 3y ago
The most common point is that they're safe to share between threads making parallel algorithms easier to invent, understand, and implement correctly.
You can also safely re-use sub-structures without performing a deep copy. For example, if you want to keep a sub-tree around for later you can do that in O(1) time because it's safe to keep a reference to it. If it is a mutable tree you don't know what's going to happen to it so you need to do a deep copy of the entire sub-tree you're holding on to. This can save a lot on memory allocation and copying depending on your use case.