table扩展模块新增两个搜索用函数

This commit is contained in:
MrZ626
2021-05-10 15:53:14 +08:00
parent 8571b020b9
commit f3eb95df93

View File

@@ -75,6 +75,16 @@ function TABLE.clear(G)
end
end
--Find value in [1~#]
function TABLE.find(t,val)
for i=1,#t do if t[i]==val then return i end end
end
--Find value in whole table
function TABLE.search(t,val)
for k,v in next,t do if v==val then return k end end
end
--Re-index string value of a table
function TABLE.reIndex(org)
for k,v in next,org do