- Joined
- Mar 3, 2006
- Messages
- 1,564
Finally, I applied patch 1.24. Now, I found the hashtable in the triggers but I don't know what is the a hashtable and how it works. Can someone explain this to me ?
//*********
globals
hashtable table
endglobals
function //*****
local unit u = CreateUnit(xxx)
set table = CreateHashtable()
call SaveUnitHandle(table,1,1,u)
endfunction
function otherone //****
local unit u = LoadUnitHandle(table,1,1)
endfunction
globals
private hashtable table
endglobals
function SetTimerData takes timer t, integer value returns nothing
call SaveInteger(table,0, GetHandleId(t), value)
endfunction
function GetTimerData takes timer t returns integer
return LoadInteger(table, 0, GetHandleId(t))
endfunction
set table = InitHashtable()
IMO you should avoid using hashtables directly. Table 3.0 is a library that provides a "better" (in my opinion) interface to hashtables.
// Normal arrays
local integer array table
local integer i = 4
set table[4] = 25
// HandleTables:
local HandleTable table = HandleTable.create()
local unit u = CreateUnit(...)
set table[u] = 25
// u is used as index. It's a way to link a number to a handle, in this case linking a number to a unit.
I don't understand this table in the link Eleandor. All I need is to paste that table in my map and everything is done ?
The code is documented so I'd say: read it and try to understand it.
Hashtables are no more efficient than arrays - in fact they're about 2 times slower due to taking two indeces. The advantage with hashtables is their infinite index size, so you can "attach" data to units, timers, etc, by using their "handle id" as an index.So... how much more efficient if this really?... than say... storing 304 integer variables in a single array [For current project]
I have a few arrays... So i could store them both in one hashtableh?
(yes it's a tableh Wacom ftw, Southpark ftw... ok im done)