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

[JASS] Hashtable Limit

Status
Not open for further replies.
I did a test to see the maximum amount of hashtables allowed.

Seems the cap is 255.

Here's the script I used to test it (I used KeyTimers2):

JASS:
library hashlimit initializer Init
    globals
        hashtable array hash
        integer i = 0
    endglobals
    
    function msg takes string s returns nothing
        call DisplayTextToForce(GetPlayersAll(), s)
    endfunction
    
    function Callback takes nothing returns nothing
        set hash[i] = InitHashtable()
        call SaveInteger(hash[i], 1, 2, GetRandomInt(0, 2147483647))
        call msg("Hashtable count: " + I2S(i) + "  Stored Integer: " + I2S((LoadInteger(hash[i],1,2))))
        set i = i + 1
    endfunction
    
    function Init takes nothing returns nothing
        local timer time = CreateTimer()
        call TimerStart(time, .5, true, function Callback)
    endfunction
endlibrary


So... Discuss?
 
Last edited:
Level 18
Joined
Jan 21, 2006
Messages
2,552
TheLifelessOne said:
JASS:
    function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerAddAction(t, function KTRun)
        call TriggerExecute(t)
    endfunction

Wow there are so much unnecessary crap here.

JASS:
function Init takes nothing returns nothing
    call KTRun()
endfunction

**Better Yet**
JASS:
library hashlimit initializer KTRun
...
   
... // notice the absence of your Init function.

I don't even know what to discuss about (rofl).
 
...Whats the point of using key timers 2?
Or timers for that matter.

And yes, it does seem the limit is at 257.


JASS:
scope wtf initializer onInit

    private function onInit takes nothing returns nothing
        local integer i = 1
        local hashtable HASH 
        loop
            exitwhen i > 1000
            set HASH = InitHashtable()
            call SaveInteger(HASH, 0, 1, 50)
            if not (LoadInteger(HASH, 0, 1) == 50) then
                call BJDebugMsg(I2S(i))
                set i = 1001
            endif
            set i = i + 1
        endloop
    endfunction

endscope
 
I had made a better script after I posted that, just forgot to update.

JASS:
library hashlimit initializer Init
    globals
        hashtable array hash
        integer i = 0
    endglobals
    
    function Callback takes nothing returns nothing
        set hash[i] = InitHashtable()
        call SaveInteger(hash[i], 1, 2, GetRandomInt(0, 2147483647))
        call BJDebugMsg("Hashtable count: " + I2S(i) + "  Stored Integer: " + I2S((LoadInteger(hash[i],1,2))))
        set i = i + 1
    endfunction
    
    function Init takes nothing returns nothing
        local timer time = CreateTimer()
        call TimerStart(time, .5, true, function Callback)
    endfunction
endlibrary
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Could also be the amount of hashtables that can be created in an array. It may fluctuate more depending on the time-frame in which they are created. Should be tested out.

Even over a long duration it still maxes out at 256.
 
Level 11
Joined
Apr 29, 2007
Messages
826
JASS:
library HashTest initializer init

    globals
        private hashtable array ht1
        private hashtable array ht2
    endglobals

    private function test takes nothing returns nothing
        local integer i = 0
        
        call BJDebugMsg("Hashtable 2 starting...")
        
        loop
            set ht2[i] = InitHashtable()
            call SaveInteger(ht2[i], 0, 0, 1)
            exitwhen not (LoadInteger(ht2[i], 0, 0) == 1)
            
            set i = i + 1
            exitwhen i > 8191
            
            call BJDebugMsg("Hashtable 2: " + I2S(i))
        endloop
        
        call BJDebugMsg("Hashtable 2 ending...")
    endfunction
    
    private function init takes nothing returns nothing
        local integer i = 0
        
        call BJDebugMsg("Hashtable 1 starting...")
        
        loop
            set ht1[i] = InitHashtable()
            call SaveInteger(ht1[i], 0, 0, 1)
            exitwhen not (LoadInteger(ht1[i], 0, 0) == 1)
            
            set i = i + 1
            exitwhen i > 8191
            
            call BJDebugMsg("Hashtable 1: " + I2S(i))
        endloop
        
        call BJDebugMsg("Hashtable 1 ending...")
        
        call TimerStart(CreateTimer(), 2, false, function test)
    endfunction
    
endlibrary
Just displays hashtable 2 starting and ending after hashtable 1 is filled up to index 255.
 
Level 10
Joined
Aug 15, 2008
Messages
720
I really do not see anything interesting here, nor I see any point. I mean who would need 256 hashtables for a map? I also second Poot's post, last time I tried to get discussion with posting random 1min test in other forum I failed epicly...

Really, 256 hashtables... So what? Whats SOOO important in that? Please tell me...
 
Level 10
Joined
Aug 15, 2008
Messages
720
Lots of systems uses structs, libraries and scopes. Besides Hashtables are helpful for GUI MUI. And the reason why none knew was... Cause they didn't care, they never hit the limit, thats why people doesn't know and mostly doesn't care...
 
Status
Not open for further replies.
Top