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

[JASS] Need help with hashtable.

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hi guys, I wonder how hashtable access its data, please see the following example:
JASS:
function example takes nothing returns nothing
	...
	call SaveReal(hash,98765432,0,1)
	....
	call LoadReal(hash,98765432,0)
endfunction

//Compare to the following parent key

function example takes nothing returns nothing
	...
	call SaveReal(hash,1,0,1)
	....
	call LoadReal(hash,1,0)
endfunction

//The acessing speed is different and my questions are:
//1. how big of a difference does it make?
//2. in the first example, does the parent key value got accessed immediately? or is it added up from 0 to 98765432? I hope this makes sense. :D
//   I mean how does hashtable access its keys?
//3. how about using hex number as parent key? Is it faster in that way? (I don't think so but not sure)

Edit:
I know that with more data stored in one hashtable, the accessing speed decreases. So do the two examples have the same reduction in terms of accessing speed?

How about creating a unit inside of a hashtable? Is it inefficient? If so, why?
JASS:
function example takes nothing returns nothing
	call SaveUnitHandle(hash,0,0,CreateUnit(.....))
endfunction
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
1)You will never notice the difference.
2)Immediately.
3)Hard question, someone with better knowlodge about w3 hashtables need to answer this one.
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
//3. how about using hex number as parent key? Is it faster in that way? (I don't think so but not sure)
Short answer: no. The internal integer representation is always the same.

Because accessing/storing on arrays don't require function calls.
Correct, but im pretty sure that this is not the reason why hashtables are slower than arrays. Hashtables do a bit more than just storing data at a predefined place, which is the reason why you have so huge keys and still only use small amount of memory (sparse).
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
Your last edited question answer is also no, there is no difference, in terms of efficiency it is even better to do this way.
 
Status
Not open for further replies.
Top