mardi 27 novembre 2018

Two-dimensional array vs projection onto a one-dimensional with a calculated index: which is faster?

I've seen regular 2-D arrays, e.g. arr[10][12], and I've seen projections onto a 1-D arr[120] which is then indexed into with arr[y * 10 + x] (mostly in lower-level systems; I think some don't support multidimensionals?) I've seen similar questions concerning c# and ruby, but those are both interpreted languages and run differently. In a language like c or c++, which would generally be faster? Why?
Thank you.

Aucun commentaire:

Enregistrer un commentaire