Lua封装map
来源:互联网 发布:软件行业编程工具 编辑:程序博客网 时间:2024/06/05 05:05
map = {}local this = mapfunction this:new() o = {} setmetatable(o,self) self.__index = self self.count = 0 return oendfunction this:insert(k,v) if nil == self[k] then --table.insert(self,{a = b}) self[k] = v self.count = self.count + 1 print("insert") end print("insert end")endfunction this:remove(k) if nil ~= self[k] then self[k] = nil if self.count >0 then self.count = self.count - 1 end endendfunction this:getpair(k) local value = nil if nil ~= self[k] then value = self[k] print("getpair") end return valueendfunction this:clear() for k,_ in pairs(self) do if nil ~= self[k] then self[k] = nil end end self.count = 0endlocal characters = map:new()characters:insert("name1"," this Name:123")characters:remove("name1")characters:insert("name2","this Name:2")local name2 = characters:getpair("name2")print(name2)print(characters.count)for k,v in pairs(characters) do print(k,v)end
0 0
- Lua封装map
- lua封装
- lua - c++封装 dxlua
- 封装Lua for C#
- 封装Lua的调用
- Lua的C++封装
- 封装Lua for C#
- Lua的C++封装
- lua C++封装
- 封装Lua for C#
- Lua封装格式化html
- Lua封装格式化float
- Lua的C++封装
- 封装Lua for C#
- lua table封装
- js封装的MAP
- 封装获取MAP
- js封装map
- jni初体验
- 知乎:你是如何开始能写python爬虫?
- 如何判断一个点是否在一个多边形内部+三角形有向面积公式
- hdu 5178 pairs
- android:configChanges locale 改语言后,该配置不起作用的解决方案
- Lua封装map
- Python super
- hdu5615Jam's math problem
- hibernate---配置属性
- 十字链表
- 网络流建图的几点体会(给自己看的笔记,持续更新)
- 开始写博客
- 模板模式
- POJ 1065