• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Trigger] 2d integer array?

Status
Not open for further replies.
Level 3
Joined
Aug 22, 2009
Messages
51
Well, i know there is a normal integer array and hashtables, but what if i need a 2d ( 2 dimensional ) integer array?
using the hashtable is the only way?
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Well it depends on the size.

Like all 2D arrays, it can only have a finite size.

You use simple maths to make one in the indicies of a normal array.
d1*ds2+d2
d is the demension while ds is the demension size. As you can see d1 has no difined size but is restricted by the max array size (8192).
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Or you can use a dynamic array and extend the limit so that it can process more indexes. This is of course just a vJass trick, it does not "take away" those limits.

JASS:
type int2d extends integer array [200, 40000]

This will make an array with 200 maximum instances, each with a size of 200.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Berb, that purly puts multiple arrays in series and probably uses the same formla I provided. In our case thats 4 arrays in series.

SlayerII, although hashtables do seem to act like 2D arrays and can be used as them, it is still more efficent to use a proper array in a 2D mode like that I provided. Hashtable lookup is great for wide range data while keeping lookup speeds near constant but can never beat a simple array.
 
Status
Not open for further replies.
Top