bowser499
Member
- Reaction score
- 1
See the image.
Laika. said:[ http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=20023 ]
Size
Arrays in JASS all have the same max index of 8192. This means that the 'size' field for arrays in the WE is useless (to my knowledge). In this sense arrays are more like hash-tables, as you will not recieve an 'index out of bounds' error. But it also means that every array you make will occupy a certain amount of space no matter how much or little data is put into it.
[ http://jass.sourceforge.net/doc/types.shtml ]
Array variables are initialized to "empty" values (e.g., 0 for integer arrays, and null for handle arrays) and have a fixed size. Each index in an array holds a value of its declared type and is referenced with the standard bracket notation. For example, my_array[10] refers to the 11th element of my_array.
Nestharus said:[ http://www.thehelper.net/forums/showthread.php?t=137090 ]
Arrays require an index whenever they are used. The index is accessed using brackets [ ]. Arrays may contain indexes from 0 to 8191. Keep in mind that the 8191 and 0 indexex are buggy as they will not work when loading a saved game. It is safest to use 1 thru 8190. If you don't plan on saved games, then use 0 and 8191 to your heart's content. Keep in mind that the 8192 number comes from an array size of 8kb.
What Laika means by arrays taking up a certain amount of space is that an array will occupy (presumably) more space than a normal variable regardless of the number of indexes in the array. However, it does not mean that an array with 10 indexes is as large as an array with 8192 indexes.
You just acknowledged that the size of the array is relevant to the game's performance.Arrays are initialized in a function that can be overloaded if too many actions are in it. It has nothing to do with how the array works internally, and your RAM can take 160KB, anyways.
Except that a temporary variable is re-used through most of your triggers and therefore the difference in size doesn't really matter since we are only talking about one array, which also includes triggers in which an array may be necessary. Even an extreme minimalist could not make out a difference in the game's performance.That is my point. Although I may not have been completely right in my other post, the main point is that array take up more space than non-array variables. Therefore, if arrays aren't significantly easier to use than non-arrays and aren't more efficient, there is no reason to use arrays, as it would still use up more RAM.