Converting 2D arrays to 1D and accessing as either 2D or 1D

added by cyotek
4/11/2012 8:41:11 AM

4 Kicks, 160 Views

Article that shows how you can store 2D data in a 1D array using row-major order and convert locations between the two.


2 comments

dpeterson
4/11/2012 8:39:38 AM
So what kind of drawbacks are there to using this approach?

cyotek
4/11/2012 1:21:24 PM
Replied twice to your comment now and they keep disappearing. Trying one last time by adding a new comment then giving up.

To quickly sum up what I said earlier (twice!) - I don't believe there are any drawbacks, bar a tiny amount of overhead due to having a class now rather than a basic array, plus the calculations to and from 2D space. But certainly I don't have any issues at all with it for what I'm using it for.

Regards;
Richard Moss