//********* 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()
// Normal arrays local integer array table local integer i = 4 set table = 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)