From 53607f6fe7b3701fd9dcbd2ecec3a12b5257a6a4 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Wed, 31 Mar 2021 21:38:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84TABLE=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/tableExtend.lua | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Zframework/tableExtend.lua b/Zframework/tableExtend.lua index 120241fd..bbd8c8e7 100644 --- a/Zframework/tableExtend.lua +++ b/Zframework/tableExtend.lua @@ -1,5 +1,7 @@ local next,type=next,type local TABLE={} + +--Copy [1~#] elements function TABLE.shift(org) local L={} for i=1,#org do @@ -11,6 +13,8 @@ function TABLE.shift(org) end return L end + +--Copy all elements function TABLE.copy(org) local L={} for k,v in next,org do @@ -22,7 +26,9 @@ function TABLE.copy(org) end return L end -function TABLE.add(G,base)--For all things in G if same type in base, push to base + +--For all things in G if same type in base, push to base +function TABLE.add(G,base) for k,v in next,G do if type(v)==type(base[k])then if type(v)=="table"then @@ -33,7 +39,9 @@ function TABLE.add(G,base)--For all things in G if same type in base, push to ba end end end -function TABLE.complete(G,base)--For all things in G if no val in base, push to base + +--For all things in G if no val in base, push to base +function TABLE.complete(G,base) for k,v in next,G do if base[k]==nil then base[k]=v @@ -42,6 +50,8 @@ function TABLE.complete(G,base)--For all things in G if no val in base, push to end end end + +--Re-index string value of a table function TABLE.reIndex(org) for k,v in next,org do if type(v)=="string"then