// Cache-friendly version - processes pixels which are adjacent in memoryfor(unsigned int y=0; y<height; ++y){for(unsigned int x=0; x<width; ++x){... image[y][x] ...}}
来
// Cache-unfriendly version - jumps around in memory for no good reasonfor(unsigned int x=0; x<width; ++x){for(unsigned int y=0; y<height; ++y){... image[y][x] ...}}
struct Product{int32_t key;char name[56];int32_t price'}
/* create an array of structs */Product* table = new Product[N];/* now load this array of structs, from a file etc. */
/* create separate arrays for each attribute */int32_t* key = new int32_t[N];char* name = new char[56*N];int32_t* price = new int32_t[N];/* now load these arrays, from a file etc. */