local Stack = {}
function Stack:ctor()
local o = o or {};
setmetatable(o,{__index = self})
return o
end
function Stack:push(...)
local args = {...}
self.stackTB = self.stackTB or {}
if next(args) then
for i = 1,#args do
table.insert(self.stackTB,args[i])
print(args[i])
end
end
end
function Stack:pop()
local popTB = {}
if next(self.stackTB) then
table.insert(popTB,self.stackTB[#self.stackTB])
table.remove(self.stackTB)
end
end
function Stack:cont()
if next(self.stackTB) then
return #self.stackTB
end
return 0
end
local s = Stack:ctor()
s:push(1,2)
lua 实现栈
最新推荐文章于 2023-11-12 03:28:32 发布