Difference between revisions of "Pseudo Mutli-Dimensional Array (3D)"
Line 2: | Line 2: | ||
<p> | <p> | ||
A list is defined as “a heterogeneous list of the other data types”. It is linear by nature and can be thought of as a single column. At the physical level, arrays are stored in contiguous sections of memory. (Another linear structure) An algorithm is used to translate between the logical rows and columns and the physical level of addresses. | A list is defined as “a heterogeneous list of the other data types”. It is linear by nature and can be thought of as a single column. At the physical level, arrays are stored in contiguous sections of memory. (Another linear structure) An algorithm is used to translate between the logical rows and columns and the physical level of addresses. | ||
</p> | </p><p></p> | ||
<p> | <p> | ||
Consider a list with 48 elements. Normally we visualize this as a vertical column. In this case, it is convenient to think of them as 2 tables of 4 rows and 6 columns. Notice we are starting with element 1. Element zero is reserved for metadata about the size of the array. | Consider a list with 48 elements. Normally we visualize this as a vertical column. In this case, it is convenient to think of them as 2 tables of 4 rows and 6 columns. Notice we are starting with element 1. Element zero is reserved for metadata about the size of the array. |
Revision as of 15:40, 21 August 2009
In my previous article Pseudo Multi-Dimensional Array, I discussed how to acheive 2 dimensional array behavior in LSL. In this article, we will look at doing the same for a 3 dimensional array.
A list is defined as “a heterogeneous list of the other data types”. It is linear by nature and can be thought of as a single column. At the physical level, arrays are stored in contiguous sections of memory. (Another linear structure) An algorithm is used to translate between the logical rows and columns and the physical level of addresses.
Consider a list with 48 elements. Normally we visualize this as a vertical column. In this case, it is convenient to think of them as 2 tables of 4 rows and 6 columns. Notice we are starting with element 1. Element zero is reserved for metadata about the size of the array.
Layer 0
0 | 1 | 2 | 3 | 4 | 5 | |
0 | 1 | 2 | 3 | 4 | 5 | 6 |
1 | 7 | 8 | 9 | 10 | 11 | 12 |
2 | 13 | 14 | 15 | 16 | 17 | 18 |
3 | 19 | 20 | 21 | 22 | 23 | 24 |
Layer 1
0 | 1 | 2 | 3 | 4 | 5 | |
0 | 25 | 26 | 27 | 28 | 29 | 30 |
1 | 31 | 32 | 33 | 34 | 35 | 36 |
2 | 37 | 38 | 39 | 40 | 41 | 42 |
3 | 43 | 44 | 45 | 46 | 47 | 48 |
Figure 1. Indexes of a list arranged in rows and columns.