• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Simple hastable question

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hey all. What are the limits of "parent key" and "child key"?
For example:
JASS:
native SaveReal takes hashtable table, integer P, integer C, real value returns nothing

What are the limits of "P" and "C"? I know P can be a large number, how about C?
Thanks all.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
No problem. Don't quote me on the child keys length though.

Easy way to test it is try to save data to it and a 0 in child key. If both return same value then you are over the limit.

I believe anything that is past the hashtables limits is set to 0

Example: Parent key = 10 and child key = 10,000,000 ( 10m)
save 2000 or something like that to that child key then save a lower number to the same hashtable with childkey of 0.
Then try to load both and see. Both numbers should be the same. ( over the limit gets set to 0)
It may also crash i am not sure.
 
Level 11
Joined
Oct 11, 2012
Messages
711
No problem. Don't quote me on the child keys length though.

Easy way to test it is try to save data to it and a 0 in child key. If both return same value then you are over the limit.

I believe anything that is past the hashtables limits is set to 0

Example: Parent key = 10 and child key = 10,000,000 ( 10m)
save 2000 or something like that to that child key then save a lower number to the same hashtable with childkey of 0.
Then try to load both and see. Both numbers should be the same. ( over the limit gets set to 0)
It may also crash i am not sure.

Ok, I will test it tomorrow. :)
Thank you.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
child key is -8191 to 8191 ( i believe)
I'm sure it's not that, I remember using it to store handle id's on a map.

EDIT: Wait, lemme check.

JASS:
function F001 takes nothing returns nothing
    call BJDebugMsg(I2S(LoadInteger(udg_HT,0,GetHandleId(GetExpiredTimer()))))
endfunction

function InitTrig_Test takes nothing returns nothing
    set udg_HT=InitHashtable()
    call SaveInteger(udg_HT,0,GetHandleId(udg_Timer),1001)
    call TimerStart(udg_Timer,1.0,false,function F001)
endfunction

This prints "1001" on screen.

Attached the map too.
 

Attachments

  • chilkey_test.w3m
    11.9 KB · Views: 39
Level 29
Joined
Oct 24, 2012
Messages
6,543
You did not test how i said though.

Try this.

JASS:
function F001 takes nothing returns nothing
    call BJDebugMsg(I2S(LoadInteger(udg_HT,0,GetHandleId(GetExpiredTimer()))))
    call BJDebugMsg(I2S(LoadInteger(udg_HT,0,0))))
endfunction

function InitTrig_Test takes nothing returns nothing
    set udg_HT=InitHashtable()
    call SaveInteger(udg_HT,0,GetHandleId(udg_Timer),1001)
    call SaveInteger(udg_HT,0,0,5000)
    call TimerStart(udg_Timer,1.0,false,function F001)
endfunction

As i said above i believe the child key returns to 0 when it is over the 8191 key range.
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
prints out:

1001
5000

attachment.php
 

Attachments

  • child_test.JPG
    child_test.JPG
    34.7 KB · Views: 136
  • chilkey_test.w3m
    11.9 KB · Views: 33
Level 11
Joined
Oct 11, 2012
Messages
711
As far as I remember you are working yourself into vJass.
When dealing with hashtables this resource is very powerful and easy to use --> NewTable.

Probably every map, which is not fully written in GUI uses Table (either Bribe's or Vexorian's).

Yes, I am learning vJass. I will start using use Bribe's table.
Thanks. :) +Rep

Ok then i forget the limit of the childkey. Thanks for the update.

Edit: Both child and parent keys have can go from -2147483648 to 2147483647

Edited above post to reflect correct answer. Thanks guys.
Yes, the result matches your statement.
Thanks. :)
 
Level 15
Joined
Aug 7, 2013
Messages
1,337
As far as I remember you are working yourself into vJass.
When dealing with hashtables this resource is very powerful and easy to use --> NewTable.

Probably every map, which is not fully written in GUI uses Table (either Bribe's or Vexorian's).

What is the advantage of using this custom built Table over the HashTable that comes with JASS?

I am reading through the post, but its functionality looks the same.
 
Status
Not open for further replies.
Top