GITLAB

wasteland / server

Sign in
  • Sign in
  • Project
  • Files
  • Commits
  • Network
  • Graphs
  • Issues 0
  • Merge Requests 0
  • Wiki
  • server
  • src
  • utils
  • TableUtil.lua
  • 222a7d5f   httpGm Browse Code ยป
    zhouhaihai
    2020-01-06 19:48:03 +0800  
TableUtil.lua 354 Bytes
Edit Raw Blame History
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
function table.arrayToMap(tab)
	tab = tab or {}
	local len = #tab
	local result = {}
	for i = 1, len, 2 do
		result[tab[i]] = tab[i + 1]
	end
	return result
end

function table.clear(tab)
	for k, _ in pairs(tab) do
		tab[k] = nil
	end
end

function table.numbers(tab)
	local count = 0
	for k, _ in pairs(tab) do
		count = count + 1
	end
	return count
end