• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Array Size Q

Status
Not open for further replies.
Level 24
Joined
Oct 12, 2008
Messages
1,783
Eg. Trying to index 20 units across 2 factions.

Method A
10 Human Units = index 1 -10
10 Orc Units = index 11-20

Method B
10 Human Units = index 100 -110
10 Orc Units = index 200 - 210

Id like to use Method B purely for organization reasons.
TLDR; is there any problem with having an array size in the 100s, even if most of the index isn't used?
 
I recall people posting in the past that they are dynamically expanded by powers of 2. Hence even knowing the maximum used index will still not reveal the actual underlying size, unless maybe some maths were performed on it. However why one would ever need to know this is beyond me.
it would mean it might do a tiny difference in memory if higher indices are used, but this, or unused indices are not any issue. Maybe hashtable can make sense, too, for your reasons.
 
Level 14
Joined
Jan 16, 2009
Messages
716
I am not aware of the implementation details of arrays in Jass.
If they are allocated in one go to the maximum size there is no difference between the two methods.
However, I remember reading they might be dynamically allocated in power of 2 steps. This means actually using a higher index as the base would "waste" the memory allocated for the indices under your first used index. It would also "waste" some indices if using method A would put you in a lower bracket.

Also be aware that the maximum array size is JASS_MAX_ARRAY_SIZE = 32768. This means the last valid index is 32767.

All in all, I wouldn't worry about it for your case.
 
Last edited:
Status
Not open for further replies.
Top