I am new to CLI/c++ and have some question on the 2 type of array stated above. I am doing some numerical calculation on large number of sample and face some problem with the speed on accessing the data in array.
As example, accessing data from
is far slower compare to
I wrote finish a code using dynamic array and it run faster compare to the one using CLI::array.
Anyone know why this happen? Is it the way i write my code wrong? Currently working in console enviroment but will move to GUI so i plan to change all the the array to CLI::array. Would C# be better if i plan to construct the program?
As example, accessing data from
Code:
array<int>^ data = gcnew array<int>(1000000);
for(int i = 0; i < data->GetLength(0); i++){[INDENT]data[i] = i;[/INDENT]
}
Code:
int *data;
data = new int[1000000];
for(int j = 0; j <1000000; j++){[INDENT]data[j] = j;[/INDENT]
}
Anyone know why this happen? Is it the way i write my code wrong? Currently working in console enviroment but will move to GUI so i plan to change all the the array to CLI::array. Would C# be better if i plan to construct the program?
Comment