3 ms·
You can also emulate a 2D array in 1D. For array[w][h] you would allocate array[w * h] and instead of indexing array[row][col] you would index array[w * row + c
by krapp 5y ago
You can also emulate a 2D array in 1D. For array[w][h] you would allocate array[w * h] and instead of indexing array[row][col] you would index array[w * row + col]. Wrap all of that in a nice API and for all intents and purposes it's the exact same thing.
see https://stackoverflow.com/questions/2151084/map-a-2d-array-onto-a-1d-array https://stackoverflow.com/questions/2151084/map-a-2d-array-o...