| 01-07-2003, 12:23 PM | #1 |
Guest | OK, i have fourth technical questions about array and memory. First question: When i create an integer array (for exemple) i do not choose his dimension. So how many item could i use in an array : i[1], i[2], i[3], ... i[?] Second question: i create an integer array (i) and use only 3 (or more) value only: i[5], i[18] and i[234] (exemple) Is this array use only 3 slots of memory, or 234 (234 because my greater value is in the 234th slot, here) So is it better to create i[1..3] ? Third: Is there i[0] ? The first entry of the array is 0 or 1 ? Fourth question and last question: Could we create 2dimension array ? |
| 01-07-2003, 01:28 PM | #2 |
first question: no, you dont need to, and i dont know why... skipping second question third question: first entry is 0 so there is an i[0] fourth: nope, theres none BUT! you can use a function to analyze a single array into a 2d one. Here's what ive learned from AIAndy: function x takes integer x, integer y returns integer return x*(size of 2darray you want)+y endfunction then you just call it on the index of your single array like i[x(1,2)]. hope this helps |
| 01-07-2003, 01:42 PM | #3 |
1. WarCraft III dynamically resizes arrays based upon how many values you have. 2. Common programming knowledge of arrays dictates that each slot must be filled with a value, even if that value is 0 or null. This is of course assuming the WarCraft III compensates for arrays laid out in this improper fashion by filling the empty slots with null values. So, my guess would be that yes, it does take up more memory. Of course, why on earth would you want to use an array in that fashion? 3. Yup, first entry is 0 4. WarCraft III doesn't support 2 dimensional arrays, to my knowledge. You can use the method proposed in spekkio's response. |
| 01-07-2003, 02:08 PM | #4 |
For the fourth question, I've been using string arrays as a makeshift 2D array. You might find it easier to work with than the other method, or not. |
