objective c - Does subarrayWithRange create a copy when executed on immutable array (NSArray)? -


Suppose I have an irreversible NSArray and want to create several sub-arrays. I can use subrearwinder on the original array I am able to get a new NSARR. What is the shared copy of the new copy with the old copy?

In the worst case scenario, I can create sub-array for each element of the original array (with that element starts at the beginning and end), so it's a linear and a square memory Uses a Difference Between Usage Patterns

This is unfortunate but the implementation of the apple is not an open source, so we can not say for sure However, by simple testing it seems that it makes a new copy of the sub array.

When you are right that this square can lead to memory usage patterns, it is also efficient in some cases. Imagine that you have a very large array, and if you want only a small sub-array, the large array will not be delicated, if sub-ray re-uses the back-end array.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -