- Joined
- Apr 27, 2008
- Messages
- 2,455
simple dynamic data structure
I want an easy-to-make-and-use-from-crash dynamic data structure.
I need to store X things and get them later.
I don't need to keep the relative order, so if the best choice is not a stack i don't care.
It must be dynamic, so simple stacks with an integer array like the blue version of TimerUtils is not enough.
First i thought that was as simple as that :
Now, i use the Stack s :
But then i've realized that .next pointers are not erased, in fact the best idea i have is to use a double linked list instead, then i can erase all pointers going through the Stack.
Someone has a better idea ?
I want an easy-to-make-and-use-from-crash dynamic data structure.
I need to store X things and get them later.
I don't need to keep the relative order, so if the best choice is not a stack i don't care.
It must be dynamic, so simple stacks with an integer array like the blue version of TimerUtils is not enough.
First i thought that was as simple as that :
JASS:
...
private struct Stack
lightning light
thistype next
endstruct
...
local Stack s
local Stack temp
set s = Stack.create()
set temp = s
loop
// ...
exitwhen ...
set temp.next = Stack.create()
set temp = temp.next
set temp.light = AddLightningEx("HWPB",true,GetUnitX(caster),GetUnitY(caster),100,GetUnitX(ll.enum),GetUnitY(ll.enum),10)
endloop
Now, i use the Stack s :
JASS:
...
local Stack s = ...
call s.destroy()
loop
set s = s.next
exitwhen s == 0
call DestroyLightning(s.light)
set s.light = null
call s.destroy()
endloop
endfunction
But then i've realized that .next pointers are not erased, in fact the best idea i have is to use a double linked list instead, then i can erase all pointers going through the Stack.
Someone has a better idea ?