- Joined
- Jul 10, 2007
- Messages
- 6,306
JASS:
library Queue
//static method create takes nothing returns thistype
//method destroy takes nothing returns nothing
//method enqueue takes thistype node returns nothing
//method dequeue takes nothing returns nothing
//method clear takes nothing returns nothing
module Queue
private static integer c = 0 //instance count
readonly thistype next
readonly thistype last
static method createQueue takes nothing returns thistype
local thistype this = thistype(0).next
if (0 == this) then
set this = c + 1
set c = this
else
set thistype(0).next = next
endif
set next = 0
set last = this
return this
endmethod
method enqueueNode takes thistype node returns nothing
set last.next = node
set node.next = 0
set last = node
endmethod
method dequeueNode takes nothing returns nothing
set next = next.next
if (0 == next) then
set last = this
endif
endmethod
method clearQueue takes nothing returns nothing
if (this != last) then
set last.next = thistype(0).next
set thistype(0).next = next
set next = 0
set last = this
endif
endmethod
method destroyQueue takes nothing returns nothing
set last.next = thistype(0).next
set thistype(0).next = this
endmethod
endmodule
endlibrary
Last edited: