HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Structs

07-04-2008, 07:55 PM#1
chobibo
Hi guys just wanted to know if the struct allocator is implementing a linked list? just curious. Thanks!
07-04-2008, 08:03 PM#2
Alexander244
If your curious: (an empty struct)
Collapse JASS:
//JASSHelper struct globals:
globals
    constant integer si__SomeStuct=1
    integer si__SomeStuct_F=0
    integer si__SomeStuct_I=0
    integer array si__SomeStuct_V
endglobals

//Generated allocator of SomeStuct
function s__SomeStuct__allocate takes nothing returns integer
    local integer this=si__SomeStuct_F
    if (this!=0) then
        set si__SomeStuct_F=si__SomeStuct_V[this]
    else
        set si__SomeStuct_I=si__SomeStuct_I+1
        set this=si__SomeStuct_I
    endif
    if (this>8190) then
        return 0
    endif
    set si__SomeStuct_V[this]=-1
    return this
endfunction

//Generated destructor of SomeStuct
function s__SomeStuct_destroy takes integer this returns nothing
    if this==null then
        return
    elseif (si__SomeStuct_V[this]!=-1) then
        return
    endif
    set si__SomeStuct_V[this]=si__SomeStuct_F
    set si__SomeStuct_F=this
endfunction
07-05-2008, 02:10 AM#3
DioD
Yes, this is single side unstructured linked list.

To get any compiled code you need to make any error and scroll dialog window to section after globals.