HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Destroying a Linked-List

03-24-2008, 01:33 AM#1
GosuSheep
Can someone explain the idea behind expressions or give me an algorithm for destroying all items in a linked list?

In, C++, you can simply go through the list and the address of each element to "TEMP" then destroy temp.

If you were to do that in jass, it would be something like

set temp = list
list = list.next
destroy temp

But it doesn't work for me.
Help with the jass algorithm??



Replies are greatly appreciated
03-24-2008, 01:44 AM#2
Vexorian
Quote:
set temp = list
list = list.next
destroy temp

But it doesn't work for me.
But it should.
03-24-2008, 04:11 AM#3
zen87
you should have something like this...

Collapse JASS:
node left
node right = start //start = beginning of the link list
loop
    left = right
    if right!=-1 then //null pointer... you'll have to initialize this one in your constructor
        right = right.next
    else
        exitwhen true
    endif
    left.destroy()   
endloop