Question very simple – say, i got function, which receives array as its arguments
void calc(double[] data)
how do “split” this data in two subarrays and pass to sub functions like this
calc_sub(data(0, length/2));
cals_sub(data(length /2, length /2));
i hope, you got the idea – in c++ i would write this
void calc(double * data, int len)
{
calc_sub(data, len / 2); //this one modifies data!!
calc_sub(data + len / 2, len / 2); //this one modifies data too!!
}
How to do same in C# without unecesary memory copying?
I would need 2 memory copies here.
1) from data to splitted data
2) calc_sub
3) from splitted data back to data! This is huge waste of time and memory!
Depending on what calc_sub does, you can make a IEnumerable class which takes the array and iterates over some part of the array. Something like ArraySegment, but better.