2d arracys

Status
Not open for further replies.
Fixed-size 2D-Arrays:
save/load stuff to arrays like this:
array[x*n+y] = value
where n is the width of the array

Example of a 2D-Array with 3x3 slots:
Code:
     0.| 1.|.2

0.   1 | 2 | 3
     ----------
1.   4 | 5 | 6
     ----------
2.   7 | 8 | 9


width of 3


array[0*3+0] = 1 | array[0*3+1] = 2 | array[0*3+2] = 3
------------------------------------------------------
array[1*3+0] = 4 | array[1*3+1] = 5 | array[1*3+2] = 6
------------------------------------------------------
array[2*3+0] = 7 | array[2*3+1] = 8 | array[2*3+2] = 9


array[0] = 1 | array[1] = 2 | array[2] = 3
------------------------------------------
array[3] = 4 | array[4] = 5 | array[5] = 6
------------------------------------------
array[6] = 7 | array[7] = 8 | array[8] = 9
make sure you don't go over 8190

or use vJASS and this http://www.wc3c.net/vexorian/jasshelpermanual.html#twodarray

Dynamic 2D-Arrays:
1. use hashtables http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/hashtables-mui-133407/
2. use 3 arrays
one for data, one for previous and one for next slot id
make sure you change the next and previous slot when adding/removing data

for further questions use search (google/forum search)
 
Last edited:
Status
Not open for further replies.
Top