• 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.

[Solved] LinkedList error

Status
Not open for further replies.
Level 6
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:
Status
Not open for further replies.
Top