title: What is the most efficient way of storing data between a multi-dimension array, and a single array?
body: <p>Essentially I'm not sure how to store a 3D data structure for the fastest access possible as I'm not sure what is going on under the hood for multi-dimensional arrays.</p>
  
  <p>NOTE: The arrays will be a constant and known size each and every time, and each element will be exactly 16 bits.</p>
  
  <p>Option one is to have a multi-dimension array <code>data[16, 16, 16]</code> and simply access via <code>data[x, y, z]</code> option two is to have a single dimension array <code>data[16 * 16 * 16]</code> and access via <code>data[x + (y * 16) + (z * 16 * 16)]</code>.</p>
  
  <p>As each element should only be 16 bits long, and I have a suspicion that a multi-dimension array would store a lot of references to other arrays internally at a minimum of 32 bits per one, that is a lot of wasted memory. However, I fear it may be faster than running the equation specified in option two each time, and speed is key to this project.</p>
  
  <p>So, can anyone enlighten me as to how much difference in speed there would likely to be compared to how much difference in memory consumption?</p>