Stephan Schroeder10/15/2019, 1:19 PM
Artyom Degtyarev [JB]10/15/2019, 1:21 PM
serebit10/15/2019, 1:21 PM
in the standard library merely obscures the methods of modifying the data in the list.
Dias10/15/2019, 1:22 PM
Alternative: Use mutable collections, but once they are populated expose them only though their read-only interfaces. This pattern is mostly used in the standard library collection operations. Pro: mutable collection implementations are generally more memory efficient, require less allocations during and after their populating. Con: collection can be cast back to mutable (e.g. involving platform types), and then unexpectedly mutated. Con: different snapshots of a collection do not share any element storage. Con: defensive copying of the resulting collection is still required later in a chain of operations. Con: mutable collections need safe publication to share them to a different thread.
Marko Mitic10/15/2019, 1:22 PM
Stephan Schroeder10/15/2019, 2:43 PM