• 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.

Indexing - What is it!?

Status
Not open for further replies.
Level 9
Joined
Apr 19, 2011
Messages
447
Hi.

I want to know what is this thing called "indexing".
I am a GUI user, and I often search in the spells section of THW, looking for cool spells, to download them and learn new things from them.
A short time ago I introduced myself to hashtables and IDs, doing exactly this.
However, I've recently seen a lot of spells that use this "indexing" thing. I can't understand what is it, or how can I use it.
Could someone give me a quick explanation so I can figure out what's it?

Thanks in advance.

Regards
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
The Unit Indexer is a system that assigns a value to every unit based on it's custom value. That value is between 0 and 8190 (the max array size) so you can access any unit by the custom value of the picked unit, instead of using hashtables, which is slower and more resource consuming.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Indexing in WarCraft III is a form of memory allocation algorithm that allocates working set in a non-fragmented way. Within the working set the allocation can become fragmented but any modifications to the working set will be non-fragmented. It is used in WarCraft III arrays as they are dynamic arrays that support increasing only in powers of 2 with a maximum size of 2^13. This keeps memory allocation for such arrays as low as possible since new indexes will be next to already allocated indices and used only if all previously used indices have been allocated.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
It should be noted that arrays start from index 0. Failing to use index 0 by an off by 1 error wastes an array index.

The size field in GUI arrays is only how many indices are initialized on map load. The actual array size is defined during runtime based on what indicies become set. The algorthim used is a dynamic array which lacks the capability to reduce in size.
 
Status
Not open for further replies.
Top