
lua 中有快速清空table的函数或者方法没
2个回答
展开全部
直接
tablename=nil
或者
tablename={}
------------------------------------------------------------------------------------------
清空的意思是把表里的所有东东都清空吧? 直接={}就行。
关于内存占用这个问题不用担心,lua的垃圾回收机制会在下次gc时把引用计数为0(就是原先)的table在内存中自动清除。
tablename=nil
或者
tablename={}
------------------------------------------------------------------------------------------
清空的意思是把表里的所有东东都清空吧? 直接={}就行。
关于内存占用这个问题不用担心,lua的垃圾回收机制会在下次gc时把引用计数为0(就是原先)的table在内存中自动清除。
展开全部
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.
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.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询