I have an array, say:
var arr1 = new [] { 1, 2, 3, 4, 5, 6 };
Now that the size of my array exceeds 5, I want to resize the current array to 3 and create a new array containing the top 3 values, so after this action:
arr1 = new [] { 1, 2, 3 };
newArr = new [] { 4, 5, 6 };
What is the fastest way to do this? I think I’ll have to look into an uncontrollable corner, but I won’t tell you.
Additional Information:
- Arrays must be scalable without major performance gains.
- Arrays will only contain Int32
- The purpose of the array is to group the numbers in my source array without sorting the entire list.
In short: I want to split the following input array:
int[] arr = new int[] { 1, 3, 4, 29, 31, 33, 35, 36, 37 };
at
arr1 = 1, 3, 4
arr2 = 29, 31, 33, 35, 36, 37
but since ideal speed is achieved with an array size of 3, arr2it should be divided into 2 arrays with a uniform size.
Note
, (, , C, , ). , memory move - Win32 API. , :
arr1, 3arr2 3- ,
arr1, arr2