我很新的C++编程世界的,对不起,我amatuerish问题:有没有快速内存访问的技巧?
我获取存储在主存储器(1-d阵列)的数据块大,我需要访问一些数据经常有,我这样做的方式是:
float *x=new float[20];//array to store x;
int *indlistforx=new int[20];//array to store the index of x;
float *databank=new float[100000000];//a huge array to store data
/... fill data to databank.../
for (int i=0;i<N;i++)//where N is a very large number;
{
/... write index to indlistforx.../
getdatafromdatabank(x, indlistforx, databank);
//Based on the index provided by indlistforx, read data from databank then pass them to x
/...do something with x.../
};
是否有访问这些数据的有效/快速的方式(x的指数是不对齐的,它是不可能被排列)?
非常感谢提前!
'new float [100000000];'?可能你住在70年代... – 2012-10-15 21:58:21
我不太明白你的问题。你的代码的某些部分运行速度太慢了吗? –
我不明白这个问题。什么是'x'? – Claudix