Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

2d array optimization

Name: Anonymous 2010-01-20 6:59

I'm writing some program (C++) which will heavily depend on bitmaps... and it needs to be ultrafast.
I thought of implementing:
- 2d arrays: bitmap[y][x]=0xdeadbeef;
- 1d arrays: bitmap[y_+x]=0xdeadbeef; where y_ = y*w, recalculated as rarely as possible
- vectors.
The point is it needs to be fast. I will often need to traverse every bitmap's cell in usual order (y=0..h, x=0..w). Having that in mind, which of the options above is the best?

Name: Anonymous 2010-01-20 11:17

Does the structure of a 2D array in memory look different than the structure of a 1D array?
No. The blocks are contiguous regardless. A two dimensional array is basically syntactic sugar.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List