- Joined
- Oct 23, 2011
- Messages
- 182
is there a problem with this list?
JASS:
struct PercentMod extends array
thistype prev
thistype next
real percent
static integer index = 0
method destroyHead takes nothing returns nothing
set .next.prev = thistype(0).prev
set thistype(0).prev = this
endmethod
method destroy takes nothing returns nothing
set .prev.next = .next
set .next.prev = .prev
set .prev = thistype(0).prev
set thistype(0).prev = this
endmethod
static method allocate takes nothing returns thistype
local thistype this = thistype(0).prev
if this == 0 then
set index = index + 1
set this = index
else
set thistype(0).prev = .prev
endif
return this
endmethod
static method createHead takes nothing returns thistype
local thistype this = thistype.allocate()
set .prev = this
set .next = this
return this
endmethod
static method create takes thistype head, real v returns thistype
local thistype this = thistype.allocate()
set .prev = head.prev
set head.prev.next = this
set head.prev = this
set .next = head
set .percent = v / 100.
return this
endmethod
endstruct
Last edited: