lua 中有快速清空table的函数或者方法没

 我来答
福喜900
2015-01-23 · TA获得超过6.1万个赞
知道大有可为答主
回答量:1.1万
采纳率:0%
帮助的人:1.1亿
展开全部
直接
tablename=nil
或者
tablename={}

------------------------------------------------------------------------------------------
清空的意思是把表里的所有东东都清空吧? 直接={}就行。

关于内存占用这个问题不用担心,lua的垃圾回收机制会在下次gc时把引用计数为0(就是原先)的table在内存中自动清除。
那年的七年之痒
2015-11-20 · TA获得超过285个赞
知道答主
回答量:221
采纳率:80%
帮助的人:54.6万
展开全部
LUA – Array commands

LUA – Array commands example
[edit]
Clear table command

You can easily clear a complete table with the Clear() command.

local table = q.GetTable("TableName")
table:Clear()

This deletes all rows of all columns in an array table
[edit]
Erase command

With the Erase() command you can erase a column or a row.
[edit]
Erase column

With the Erase() command you can erase a column.

local table = q.GetTable("TableName")
local column = table:GetColumn("ColumnName")

column:Erase()

This erases all row in of one column in a table
[edit]
Erase row

With the Erase() command you can erase a column or a row.

local table = q.GetTable("TableName")
local row = table:GetRow(0)

row:Erase()

This erase all data in the row ID 0 of all column of a table. It does NOT remove-delete the row from the table, so it does not effect the total amount of rows!
[edit]
Delete command

With the Delete command you can delete-remove a row from all column in a table.

local table = q.GetTable("TableName")
local row = table:GetRow(0)

row:Delete()

This delelets the row ID 0 (and it data) from all columns in a table. This will affect the total amount of row in a table.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式