GetTriggerUnit-
DogEntrepreneur
- Reaction score
- 129
For my map, I'm using many hashtables so I though that making an hashtable recycling snippet would be nice. Now, I need to know if it's well done.
Comments?
Comments?
JASS:
library HashtableUtils initializer init
globals
private constant integer MAX_HASHTABLES_ALLOWED = 500
private hashtable array hasht
private boolean array used
endglobals
function NewHashtable takes nothing returns hashtable
local integer i = 0
loop
set i = i + 1
if used<i> == false then
return hasht<i>
endif
exitwhen i > MAX_HASHTABLES_ALLOWED
endloop
endfunction
function ReleaseHashtable takes hashtable h returns nothing
local integer i = 0
call FlushChildHashtable(h)
loop
set i = i + 1
if hasht<i> == h then
set used<i> = false
return
endif
exitwhen i > MAX_HASHTABLES_ALLOWED
endloop
endfunction
private function init takes nothing returns nothing
local integer i = 0
loop
set i = i + 1
set hasht<i> = InitHashtable()
set used<i> = false
exitwhen i > MAX_HASHTABLES_ALLOWED
endloop
endfunction
endlibrary
</i></i></i></i></i></i>