1D vs 2D arrays

woopdeedoowoopdeedoo Posts: 109Member
edited October 2017 in Programming

Is there any significant performance to be gained with 1D arrays instead of 2D arrays?
I mean, both in terms of looping and accessing items.

var j = 0 # I don't do it 1D in a while, so this may be totally wrong. I hope you get my point. for i in range( w*h ): j = i/w array[ i+j*w ] = ...
... instead of...
for j in range( h ): for i in range( w ): array[j][i] = ...

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file