• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

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,204
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,204
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