• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] About linked lists

Status
Not open for further replies.
[jass=]
integer array next
integer array prev

integer instanceCount = 0
integer array recycler

function add takes integer node returns nothing
set next[node] = 0
set prev[node] = prev[0]
set next[prev[0]] = node
set prev[0] = node
endfunction

function remove takes integer node returns nothing
set next[prev[node]] = next[node]
set prev[next[node]] = prev[node]
endfunction

function loop takes nothing returns nothing
local integer this = next[0]
loop
exitwhen this == 0
// Your code here using "this" as the current index :D
set this = next[this]
endloop
endfunction

function allocateIndex takes nothing returns integer
local integer index = recycler[0]
if index == 0 then
set instanceCount = instanceCount + 1
set index = instanceCount
else
set recycler[0] = recycler[index]
endif

return index
endfunction

function deallocateIndex takes integer index returns nothing
set recycler[this] = recycler[0]
set recycler[0] = this
endfunction[/code]

Im a confused about this.

Can someone post some example usage(no vJASS please)
 
Status
Not open for further replies.
Top