Immutable data structures performance

Viewed 3963

I don't get how can something as a Set be immutable and still have an acceptable performance.

From what I've read in F# Sets internally use Red Black Trees as their implementation. If each time we want to add something new to a Red Black Tree we have to basically recreate it, how can it have ever good performance? What am I missing here?

Although I am asking this for F#'s Sets, I think this is as relevant in any other language which has or uses immutable data structures.

Thanks

8 Answers
Related