I have a C pointer array from which I want to get the data in Swift. However, I need to get the data with a specific stride/stepsize and without a for loop to keep it efficient.
To get all the data I would do this:
let dataStrided = Array(UnsafeBufferPointer(start: dataPtr, count: arraySize))
But I don’t know how to obtain the unstrided data. I would think of using the Swift function stride, but the following (of course) doesn’t work:
let dataUnstrided = dataStrided[0.stride(to: arraySize-stepSize, by: stepSize)]
Would there be an efficient method to do this and avoiding a for loop?