I've had the use for a stack several times so now when the modules was released I created one that's easy to use and works well because I needed it
JASS:
library Stack
// This is a basic module for creating stacks.
// To add something to the top of the stack us <struct var>.push(data)
// and to retrieve the last added item use <struct var>.pop()
// If you want to clean all datas added to the stack then use <struct var>.reset()
//
// This stack works like this: Last in first out, this can easily be showed with this example
// call .push(1)
// call .push(2)
// call .push(3)
//
// call BJDebugMsg(I2S(.pop()))
// call BJDebugMsg(I2S(.pop()))
// call BJDebugMsg(I2S(.pop()))
// That piece of code will display 3, 2, 1 because of the way a stack is created.
module Stack
private static integer ERROR_RETURN = -8784574 // Just using something random if you want to check if
// it reterned an error since you tried to pop too many datas
private static integer array DATAS[8190]
private static integer N = 0
method push takes integer data returns nothing
set .DATAS[.N] = data
set .N = .N + 1
endmethod
method pop takes nothing returns integer
if .N > 0 then
set .N = .N - 1
return .DATAS[.N]
endif
return .ERROR_RETURN
endmethod
method reset takes nothing returns nothing
local integer i = .N
loop
exitwhen i < 0
set .DATAS<i> = 0
set i = i - 1
endloop
set .N = 0
endmethod
endmodule
endlibrary</i>