- Joined
- May 9, 2014
- Messages
- 1,820
I wonder how this will behave (indexing). Am I doing something wrong with indexing this?
JASS:
private struct lolStruct extends array
private static integer count = 0
private static thistype recycle = 0
private thistype recNext
private static thistype first = 0
private static thistype last = 0
private thistype next
private thistype prev
method destroy takes nothing returns nothing
set recNext = recycle
set recycle = this
if this.prev == 0 then
set first = this.next
else
set this.prev.next = this.next
endif
if this.next == 0 then
set last = this.prev
else
set this.next.prev = this.prev
endif
endmethod
static method create takes nothing returns thistype
local thistype this
if recycle == 0 then
set count = count + 1
set this = count
else
set this = recycle
set recycle = recycle.recNext
endif
return this
endmethod
method push takes nothing returns nothing
if recycle == 0 then
set first = this
set last = this
set this.next = 0
set this.prev = 0
else
set this.next = first
set this.prev = 0
set first.prev = this
set first = this
endif
endmethod
method queue takes nothing returns nothing
if recycle == 0 then
set first = this
set last = this
set this.next = 0
set this.prev = 0
else
set this.prev = last
set this.next = 0
set last.next = this
set last = this
endif
endmethod
endstruct
Last edited: