Blame view

src/utils/TableUtil.lua 354 Bytes
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
1
  function table.arrayToMap(tab)
222a7d5f   zhouhaihai   httpGm
2
  	tab = tab or {}
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
3
4
5
6
7
8
  	local len = #tab
  	local result = {}
  	for i = 1, len, 2 do
  		result[tab[i]] = tab[i + 1]
  	end
  	return result
23d89d13   zhouahaihai   冒险 结构
9
10
11
12
13
14
  end
  
  function table.clear(tab)
  	for k, _ in pairs(tab) do
  		tab[k] = nil
  	end
c384626d   zhouhaihai   好友
15
16
17
18
19
20
21
22
  end
  
  function table.numbers(tab)
  	local count = 0
  	for k, _ in pairs(tab) do
  		count = count + 1
  	end
  	return count
be83d162   zhouahaihai   登陆成功。 增加数据结构修正功能
23
  end