It is impossible to find out how you are going to use this array. The selection size does not necessarily correspond to the element number, so you cannot just use the distribution size (even if it is available).
This is a profound error in other languages, not C ++. You achieve the desired functions with std :: vector, but still retain raw access to arrays. Maintaining this raw access is critical for any code that actually needs to do some work.
You will perform operations on subsets of the array many times, and when you have additional accounting built into the language, you must redistribute the subarrays and copy the data to manipulate them using the API, which expects a managed array.
Just consider the trivial case of sorting data items. If you manipulate arrays, you cannot use recursion without copying data to create recursive recursive recursions to create new gifts.
Another example is FFT, which recursively manipulates data starting from 2x2 butterflies and returns back to the entire array.
To fix a managed array, you now need “something else” to fix this defect, and that “something else” is called “iterators”. (Now you control arrays, but almost never pass them to any functions, because you need iterators + 90% of the time.)
Quazil Apr 7 '16 at 18:18 2016-04-07 18:18
source share