• 🏆 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!

Are hashtables infinite?

Status
Not open for further replies.
Level 11
Joined
Dec 8, 2006
Messages
334
Hi
I've created some mighty bad-ass system in my map that cover knockback, missile projectiles and whatnot...
It's all done with units custom values + sheetload of arrays, everything done before hashtables were there for me to use...
Now, I've been wondering about re-writting the code and converting it all from custom values to hashtable values...

...Is it worth it?

-Are hashtables infinite? I know that unit custom value has maximum integer number of something over eight-thousaaaaaaaand
-Are they slower/faster/something?
-Is there something else I should take into account?

Ok thanks for any reply, cheers :)
 
- 256 hashtables maximum (shouldn't really need to go past that). I forgot what the exact maximum keys and stored values are, (DioD made a post with the maximums in wc3c, but wc3c is down) but it is something over a billion so it isn't something to worry about.
- They are fast, but not as fast as arrays and custom values. (difference in speed is unnoticeable though)
- If you are likely to get custom values > 8191, then switch to hashes, otherwise custom values will be fine. You can also include optionally which to choose.

Fire away if you have any more questions. :)
 
FYI, Hashtables also enable you to have instance-associated-arrays. In my TimeTravel system, I do this:

JASS:
SaveReal ( hash , this * 3 , savepoint , x ) ;
SaveReal ( hash , this * 3 + 1 , savepoint , y ) ;
SaveReal ( hash , this * 3 + 2 , savepoint , z ) ;

x = LoadReal ( hash, this * 3 , savepoint ) ;
y = LoadReal ( hash, this * 3 + 1 , savepoint ) ;
z = LoadReal ( hash, this * 3 + 2 , savepoint ) ;

This enables my system to have 3 arrays indexed to each instance, causing 'hash' to act as a 3-dimensional array.
 
Level 11
Joined
Dec 8, 2006
Messages
334
You can also include optionally which to choose.

What do you mean? :)

Fire away if you have any more questions. :)

Thanks man! And thanks for the reply as well

JASS:
SaveReal ( hash , this * 3 , savepoint , x ) ;
SaveReal ( hash , this * 3 + 1 , savepoint , y ) ;
SaveReal ( hash , this * 3 + 2 , savepoint , z ) ;

Sounds cool... But wait, what does "this" refer to?

Axarion said:
They are like 60% slower than arrays but quite fast though.
Aw that sounds like quite a lot o_O
I'm using about hundred of values every 0.02 seconds!

Let me think some more... I don't need custom values for dead units - I'm certainly not going to have more than 8191 units on the map at the same time. So... I could theoretically fix the maximum custom value limit by looping through all living units on the map once the custom value gets past 8190, and change their values while in there.
Would it be faster than using hashtables though? (it shouldn't happen too often though)
 
Level 11
Joined
Dec 8, 2006
Messages
334
Hold on a minute!

I just tested this:

  • Melee Initialization
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Set i = 999999
      • Unit - Set the custom value of Footman 0000 <gen> to i
      • Game - Display to (All players) the text: (String((Custom value of Footman 0000 <gen>)))
And it worked!

Could anyone riddle me this? Because my explanation would be something along the lines of: Maximum value in an array is 8191, but it seems to be a lot bigger for casual integer, which is a custom value, for example...

If I'm not mistaken, then it's awesome! and it solves the problem as well it seems...
Or is something fishy behind it?

Including proof map:
 

Attachments

  • MaxIntegerOo.w3x
    16.5 KB · Views: 50
Level 11
Joined
Dec 8, 2006
Messages
334
he means if you have 8191 units with custom values defined, the next one won't store a custom value.

like doing this
set V[8192] = 100
call BJDebugMsg(I2S(V[8192]))

wouldn't even type anything, as it would be referring a null value.

Fcuk!

So if I understand it well, I can have 8191 units, each holding custom value, but it's irrelevant how big the custom value is?

Hmmm

So can I null units custom value somehow?
Each time a creep dies, I don't need to store its value anymore :S
 
Status
Not open for further replies.
Top