HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Messing around with indexing.

05-16-2009, 08:13 AM#1
TriggerHappy
Just want to know your thoughts.

I didn't submit it because there are already other indexing systems.

I'm just going to use this one for personal use.

Anyways, would like your thoughts on the code, improvments, questions ect..

If i'm going to use this for personal use, hopefully theres nothing dangerously wrong with the code.

Expand JASS:

Collapse JASS:
scope Demo initializer InitTrig

    struct timerdata
        string name
    endstruct
    
    function Remove takes nothing returns nothing
        local index sometimer = index.get(GetExpiredTimer()) // Get the expired timer
        local timerdata d = sometimer // load the timers attached struct
        call BJDebugMsg(d.name) // display the timers stored name
        call sometimer.flush() // clears the index so it can be re-used.
    endfunction

    private function Actions takes nothing returns nothing
        local timer t = CreateTimer() // create some timer
        local index sometimer = index.add(t) // create the index and store the timer
        local timerdata d = sometimer // Some struct that will store data to the timer
        
        set d.name = "SomeTimer" // set the name of the timer
        
        call TimerStart(t, 1, false, function Remove) // Begin the timer
    endfunction

    //===========================================================================
    private function InitTrig takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterTimerEvent(t, 0.00, false)
        call TriggerAddAction(t, function Actions)
    endfunction

endscope
05-16-2009, 10:04 AM#2
Anitarf
Why repeat index.Handle2Integer(u) instead of using i?
05-16-2009, 03:27 PM#3
TriggerHappy
Quote:
Originally Posted by Anitarf
Why repeat index.Handle2Integer(u) instead of using i?

Integer typecasting slipped my mind, fixed.
05-16-2009, 06:12 PM#4
Feroc1ty
I understand it's for your personal use, but wouldn't it get tiring of typing out "Handle2Integer" over and over again, instead of simply typing "H2I."
05-16-2009, 08:36 PM#5
TriggerHappy
Handle2Integer is only used internally, I never have to call it.
05-17-2009, 01:40 PM#6
fX_
whats the use of index.indexed?

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

does setting a struct's id
Collapse JASS:
set myStruct = i
change its configuration?
i think
Collapse JASS:
set myStruct = 0
flushes myStruct (or im soooooooooooooooooooooooooooo wrong and i have sooooooooooo many problems with stuff i have written (o shit)), then setting a struct's id has some effect on its configuration or setting to '0' is a special case contrived for flushing.

if this is true, then this method messes with your structs.