2D or 3D arrays?

millz-

New Member
Reaction score
25
I know that 2D or 3D arrays exist in the Java world, is it possible to use it in JASS? Or do I just have to resort to hashtables or game caches to store more information?

Incase someone don't get what I mean:

Integer i[u2][u3] = 1
Integer x[y1][y2][y3] = 11

Something like that.
 

Moridin

Snow Leopard
Reaction score
144
Hashtables, though different, are very similar to typical 2D arrays....at least in my opinion.
 

uberfoop

~=Admiral Stukov=~
Reaction score
177
Well, in any situation with 1d arrays, you can simulate n-dimensional arrays by treating a one-dimensional array as if it were broken up into smaller blocks. For example, this would simulate using a 90*90 array:
[ljass]set ArrayName[Index1*90+Index2][/ljass]
The problem of course is that the more you break it up, the smaller each dimension gets, since you only have 8192 indices to work with.


Also look at this.


Hashtables, though different, are very similar to typical 2D arrays....at least in my opinion.
It's not your opinion. Wc3 hashtables ARE 2d arrays.

And they're quite recommended to use for mass usage of large indices. Or to just avoid a headache. And in some cases probably wind up with faster code than vJass 2d arrays.
 

millz-

New Member
Reaction score
25
Well, in any situation with 1d arrays, you can simulate n-dimensional arrays by treating a one-dimensional array as if it were broken up into smaller blocks. For example, this would simulate using a 90*90 array:
[ljass]set ArrayName[Index1*90+Index2][/ljass]
The problem of course is that the more you break it up, the smaller each dimension gets, since you only have 8192 indices to work with.


Also look at this.



It's not your opinion. Wc3 hashtables ARE 2d arrays.

And they're quite recommended to use for mass usage of large indices. Or to just avoid a headache. And in some cases probably wind up with faster code than vJass 2d arrays.

Mhmmm...
Never thought of using multiplication to simulate a 2D index, but I did thought of this: Array[S2I(I2S(index1) + "" + I2S(index2))] and even attempted to use it, LOL. Thanks for that advice. :)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top