summaryrefslogtreecommitdiff
path: root/Resources/DefaultContent/Libraries/containers/stack.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-26 11:32:46 +0800
committerchai <chaifix@163.com>2021-10-26 11:32:46 +0800
commit0549b1e5a8a3132005e275d6026db8003cb067d2 (patch)
treef0d7751ec32ecf5c4d23997fa0ffd3450a5a755a /Resources/DefaultContent/Libraries/containers/stack.lua
parent32345800737b668011a87328cd3dcce59ec2934c (diff)
*rename folder
Diffstat (limited to 'Resources/DefaultContent/Libraries/containers/stack.lua')
-rw-r--r--Resources/DefaultContent/Libraries/containers/stack.lua67
1 files changed, 0 insertions, 67 deletions
diff --git a/Resources/DefaultContent/Libraries/containers/stack.lua b/Resources/DefaultContent/Libraries/containers/stack.lua
deleted file mode 100644
index d828c81..0000000
--- a/Resources/DefaultContent/Libraries/containers/stack.lua
+++ /dev/null
@@ -1,67 +0,0 @@
---堆栈实现
-stack = stack or {}
-
-function stack.create()
- local data = {}
-
- local function push(v)
- assert(v)
- table.insert(data, v)
- end
-
- local function pop()
- assert(#data > 0)
- table.remove(data)
- end
-
- local function peek()
- return #data > 0 and data[#data] or nil
- end
-
- local function clear()
- for i=1,#data do
- data[i] = nil
- end
- end
-
-
-
- local __tostring = function()
- local tmp = {}
- for i,v in ipairs(data) do
- tmp[#data+1 - i] = v
- end
- return table.concat(tmp, ",")
- end
-
- local __index = function(i_t, key)
- error(">> Dee: Limited access")
- end
-
- local __len = function()
- return #data
- end
-
- local __newindex = function(i_t, key, v)
- error(">> Dee: Limited access")
- end
-
- local __ipairs = function()
- error(">> Dee: Limited access")
- end
-
- local mt = {__tostring = __tostring, __index = __index, __newindex = __newindex, __ipairs = __ipairs, __pairs = __ipairs, __len = __len}
-
- local t = {
- push = push,
- pop = pop,
- peek = peek,
- clear = clear
- }
-
- setmetatable(t, mt)
-
- return t
-end
-
-return stack \ No newline at end of file