七月是什么星座| 纷扰是什么意思| 子宫前位后位有什么区别| 口爆是什么| 大姨妈是什么| 省委组织部长是什么级别| 什么是上火| 胆固醇高不可以吃什么食物| 着床后需要注意什么| 女人什么时候是排卵期| 兑卦代表什么| 刘强东开什么车| 晒伤擦什么药| 尿有泡泡是什么病| 脚气脱皮用什么药最好| 横店是什么| 内分泌紊乱是什么症状| dos是什么| 热锅上的蚂蚁是什么意思| 什么是精索静脉曲张| 频繁做梦是什么原因| 尿起泡沫是什么原因| 肩膀疼是什么原因引起的| 例假少吃什么能让量多| 最亮的星星是什么星| 糖尿病能吃什么| 内参是什么意思| 背部疼痛挂什么科| 虚岁30岁属什么生肖| 口腔医学是什么| 什么非常什么写句子| 风什么浪什么| 宝宝佛适合什么人戴| 心脏肿大是什么原因| 阴囊潮湿什么原因| 胶体是什么| 长鱼是什么鱼| 小孩夜里哭闹是什么原因| 作灶是什么意思| 硒酵母胶囊对甲状腺的作用是什么| 熊猫属于什么科| 98年的虎是什么命| 什么食物补钙| 血稠是什么原因造成的| 神经病是什么意思| 五指毛桃不能和什么一起吃| 什么是简历| 女人吃枸杞有什么好处| 蛔虫是什么动物| 2003是什么年| 卵泡刺激素高说明什么| 高考什么时候结束| 什么肉是碱性的| 为什么会有跳蚤| 麝是什么动物| 肾结石吃什么药| ige是什么意思| 梦到开车是什么意思| 棕色短裤配什么颜色上衣| 椰子水有什么好处| 伤口撒什么药粉好得快| 无花果有什么功效| 结膜水肿用什么眼药水| 用字五行属什么| fog是什么牌子| 孔雀鱼吃什么| 吃什么可以降血脂| 阳虚吃什么中药调理| 无忧什么意思| 做梦梦到捡钱是什么征兆| 国家三有保护动物是什么意思| 晚上睡觉脚抽筋是什么原因引起的| 经常偏头疼是什么原因| 跟腱是什么| dia是什么意思| 下面痒用什么药效果好| 美团是干什么的| 为什么牙齿会松动| 甲沟炎是什么| 一什么石头| 身份证号最后一位代表什么| 西洋参吃了有什么好处| 气虚是什么原因造成的| 高抬贵手是什么意思| dvf是什么品牌| 为什么会低钾| 栩是什么意思| 巩膜是什么部位| 来大姨妈吃什么好| 头总出汗是什么原因| 两个方一个土读什么| 7个月的宝宝吃什么辅食| wis是什么牌子| 诛心是什么意思| 部堂大人是什么职位| 蚂蚁爱吃什么东西| 死马当活马医是什么意思| 低压高会引起什么后果| 头头是道什么意思| 微信英文名叫什么| 巨蟹座和什么座最配对| 隐翅虫咬到擦什么药膏| 尿检阳性是什么意思| 高危型hpv有什么症状| 干贝和瑶柱有什么区别| 白癜风不能吃什么| 西洋参不能和什么一起吃| 备孕前需要做什么检查| 女生肚脐眼下面疼是什么原因| 巴黎世家是什么| 身上长水泡是什么原因| npn是什么意思| 胃不好看什么科| 47是什么生肖| ber是什么意思| 无后为大的前一句是什么| 喝水呛咳是什么原因| 生长因子是什么| 考幼师证需要什么条件| 应接不暇的暇是什么意思| 巾帼是指什么| 毫不逊色的意思是什么| 饭后痰多是什么原因| 喝什么牌子的水最健康| 利巴韦林是什么药| 血脂高有什么危害| 蔚字五行属什么| 为什么医生爱开喜炎平| 鸽子夏天喝什么水好| 58年属什么生肖| 肠系膜淋巴结是什么病| 早上7点多是什么时辰| abo是什么血型| 肺火吃什么药| 灵魂伴侣是指什么意思| 12月出生的是什么星座| 立冬北方吃什么| 艮宫代表什么| 手足口什么症状| 老母鸡煲汤放什么食材补气补血| 大腿出汗是什么原因| pending是什么状态| r车标是什么牌子| 梦女是什么意思| vca是什么牌子| 5月10日是什么星座| 炖乌鸡汤放什么配料| 欧阳修号什么| 香云纱是什么面料| 男性囊肿是什么原因引起的| 六月五号是什么星座| 沂字五行属什么| 吃海鲜忌什么| cfa是什么证书| py什么意思| 华侨是什么| 什么蚌相争| 胸口疼痛是什么原因| 负数是什么| 碱中毒是什么引起的| 心力衰竭吃什么药最好| 新生儿血糖低是什么原因| 朝是什么意思| 万岁是什么意思| 红红火火是什么生肖| 早上不晨勃是什么原因| 空调不出水是什么原因| 孕前检查什么时候去最合适| 尿道炎什么症状| 紧张的反义词是什么| 巡礼是什么意思| 霍金是什么病| 三焦湿热吃什么中成药| 绝膑而亡是什么意思| 什么是盆腔炎| 炖鱼放什么调料| 小便有刺痛感什么原因| 伤口拆线挂什么科| 弱智的人有什么表现| 云南白药治什么| 小腿痛什么原因| 孕妇吸二手烟对胎儿有什么影响| 精子什么味| 梦到高考是什么意思| 什么是冠心病| 松鼠是什么生肖| 吃葱有什么好处和坏处| 血红蛋白低吃什么药| 月支是什么意思| 肠炎吃什么食物| 刘备和刘邦什么关系| 漆皮是什么皮| 山药什么季节成熟| 山茱萸的功效与作用是什么| 万圣节为什么要送糖果| 单亲家庭是什么意思| 贡眉是什么茶| 不自觉摇头是什么病| 有才是什么意思| 夜黑风高什么意思| 黄体破裂是什么原因造成的| 柒牌男装什么档次| 虎头虎脑是什么生肖| 后援团是什么意思| 恶对什么| 什么烟贵| 牛鬼蛇神是什么意思| 术后恢复吃什么好| 辅食是什么意思| 三伏天吃什么水果好| 囊内可见卵黄囊是什么意思| 什么是金砖国家| 眼睛发痒是什么原因| 为什么老是做梦| 婴儿血小板低是什么原因| 为什么晚上不能扫地| 身上长红疙瘩很痒是什么原因| 狗狗能看见什么颜色| 猫为什么不怕蛇| 全身酸痛是什么原因| 什么是重力| 心衰的症状是什么| 人艰不拆是什么意思| 迈之灵治什么病| 羟苯乙酯是什么| 下面痒用什么药| 私处瘙痒用什么药| o型血和b型血生的孩子是什么血型| 得之坦然失之淡然是什么意思| 这是什么英语| 舌根痛吃什么药好得快| 胆囊炎是什么病| 起风疹的原因是什么引起的| 血压低有什么危险| 牙龈肿痛用什么药好得快| 吃什么回奶| 皮肤黄适合穿什么颜色的衣服| 微信证件号是什么| 守护者是什么意思| 殊途同归什么意思| 想一出是一出什么意思| 1992年什么命| 左脸颊有痣代表什么| 两个方一个土读什么| 梦遗是什么| 一什么瓜地| 餐标是什么意思| 碘伏遇到什么会变白| 女人阴虚火旺吃什么药| 中度贫血吃什么补血最快| 射手座和什么座最配对| sds是什么| 遇上方知有什么意思| 麦穗鱼吃什么| 欣字属于五行属什么| 眼睛大小不一样是什么原因| 水军什么意思| 工薪阶层是什么意思| 良性反应性改变是什么意思| 皮肤感染吃什么消炎药| 血红蛋白低吃什么| 塞保妇康为什么会出血| 什么枕头好| 谷草转氨酶是什么意思| 百度Jump to content

年度最魔性休闲射击游戏《元气骑士》全网首发

From Wikipedia
百度 离岗创业保留人事关系和待遇本市将加大对创新团队和优秀人才的奖励力度。

Documentation for this module may be created at Module:TableTools/doc

--[[
------------------------------------------------------------------------------------
--                               TableTools                                       --
--                                                                                --
-- This module includes a number of functions for dealing with Lua tables.        --
-- It is a meta-module, meant to be called from other Lua modules, and should     --
-- not be called directly from #invoke.                                           --
------------------------------------------------------------------------------------
--]]

local libraryUtil = require('libraryUtil')

local p = {}

-- Define often-used variables and functions.
local floor = math.floor
local infinity = math.huge
local checkType = libraryUtil.checkType
local checkTypeMulti = libraryUtil.checkTypeMulti

--[[
------------------------------------------------------------------------------------
-- isPositiveInteger
--
-- This function returns true if the given value is a positive integer, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a given table key is in the array part or the
-- hash part of a table.
------------------------------------------------------------------------------------
--]]
function p.isPositiveInteger(v)
	if type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity then
		return true
	else
		return false
	end
end

--[[
------------------------------------------------------------------------------------
-- isNan
--
-- This function returns true if the given number is a NaN value, and false
-- if not. Although it doesn't operate on tables, it is included here as it is
-- useful for determining whether a value can be a valid table key. Lua will
-- generate an error if a NaN is used as a table key.
------------------------------------------------------------------------------------
--]]
function p.isNan(v)
	if type(v) == 'number' and tostring(v) == '-nan' then
		return true
	else
		return false
	end
end

--[[
------------------------------------------------------------------------------------
-- shallowClone
--
-- This returns a clone of a table. The value returned is a new table, but all
-- subtables and functions are shared. Metamethods are respected, but the returned
-- table will have no metatable of its own.
------------------------------------------------------------------------------------
--]]
function p.shallowClone(t)
	local ret = {}
	for k, v in pairs(t) do
		ret[k] = v
	end
	return ret
end

--[[
------------------------------------------------------------------------------------
-- removeDuplicates
--
-- This removes duplicate values from an array. Non-positive-integer keys are
-- ignored. The earliest value is kept, and all subsequent duplicate values are
-- removed, but otherwise the array order is unchanged.
------------------------------------------------------------------------------------
--]]
function p.removeDuplicates(t)
	checkType('removeDuplicates', 1, t, 'table')
	local isNan = p.isNan
	local ret, exists = {}, {}
	for i, v in ipairs(t) do
		if isNan(v) then
			-- NaNs can't be table keys, and they are also unique, so we don't need to check existence.
			ret[#ret + 1] = v
		else
			if not exists[v] then
				ret[#ret + 1] = v
				exists[v] = true
			end
		end	
	end
	return ret
end			

--[[
------------------------------------------------------------------------------------
-- numKeys
--
-- This takes a table and returns an array containing the numbers of any numerical
-- keys that have non-nil values, sorted in numerical order.
------------------------------------------------------------------------------------
--]]
function p.numKeys(t)
	checkType('numKeys', 1, t, 'table')
	local isPositiveInteger = p.isPositiveInteger
	local nums = {}
	for k, v in pairs(t) do
		if isPositiveInteger(k) then
			nums[#nums + 1] = k
		end
	end
	table.sort(nums)
	return nums
end

--[[
------------------------------------------------------------------------------------
-- affixNums
--
-- This takes a table and returns an array containing the numbers of keys with the
-- specified prefix and suffix. For example, for the table
-- {a1 = 'foo', a3 = 'bar', a6 = 'baz'} and the prefix "a", affixNums will
-- return {1, 3, 6}.
------------------------------------------------------------------------------------
--]]
function p.affixNums(t, prefix, suffix)
	checkType('affixNums', 1, t, 'table')
	checkType('affixNums', 2, prefix, 'string', true)
	checkType('affixNums', 3, suffix, 'string', true)

	local function cleanPattern(s)
		-- Cleans a pattern so that the magic characters ()%.[]*+-?^$ are interpreted literally.
		s = s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
		return s
	end

	prefix = prefix or ''
	suffix = suffix or ''
	prefix = cleanPattern(prefix)
	suffix = cleanPattern(suffix)
	local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'

	local nums = {}
	for k, v in pairs(t) do
		if type(k) == 'string' then			
			local num = mw.ustring.match(k, pattern)
			if num then
				nums[#nums + 1] = tonumber(num)
			end
		end
	end
	table.sort(nums)
	return nums
end

--[[
------------------------------------------------------------------------------------
-- numData
--
-- Given a table with keys like ("foo1", "bar1", "foo2", "baz2"), returns a table
-- of subtables in the format 
-- { [1] = {foo = 'text', bar = 'text'}, [2] = {foo = 'text', baz = 'text'} }
-- Keys that don't end with an integer are stored in a subtable named "other".
-- The compress option compresses the table so that it can be iterated over with
-- ipairs.
------------------------------------------------------------------------------------
--]]
function p.numData(t, compress)
	checkType('numData', 1, t, 'table')
	checkType('numData', 2, compress, 'boolean', true)
	local ret = {}
	for k, v in pairs(t) do
		local prefix, num = mw.ustring.match(tostring(k), '^([^0-9]*)([1-9][0-9]*)$')
		if num then
			num = tonumber(num)
			local subtable = ret[num] or {}
			if prefix == '' then
				-- Positional parameters match the blank string; put them at the start of the subtable instead.
				prefix = 1
			end
			subtable[prefix] = v
			ret[num] = subtable
		else
			local subtable = ret.other or {}
			subtable[k] = v
			ret.other = subtable
		end
	end
	if compress then
		local other = ret.other
		ret = p.compressSparseArray(ret)
		ret.other = other
	end
	return ret
end

--[[
------------------------------------------------------------------------------------
-- compressSparseArray
--
-- This takes an array with one or more nil values, and removes the nil values
-- while preserving the order, so that the array can be safely traversed with
-- ipairs.
------------------------------------------------------------------------------------
--]]
function p.compressSparseArray(t)
	checkType('compressSparseArray', 1, t, 'table')
	local ret = {}
	local nums = p.numKeys(t)
	for _, num in ipairs(nums) do
		ret[#ret + 1] = t[num]
	end
	return ret
end

--[[
------------------------------------------------------------------------------------
-- sparseIpairs
--
-- This is an iterator for sparse arrays. It can be used like ipairs, but can
-- handle nil values.
------------------------------------------------------------------------------------
--]]
function p.sparseIpairs(t)
	checkType('sparseIpairs', 1, t, 'table')
	local nums = p.numKeys(t)
	local i = 0
	local lim = #nums
	return function ()
		i = i + 1
		if i <= lim then
			local key = nums[i]
			return key, t[key]
		else
			return nil, nil
		end
	end
end

--[[
------------------------------------------------------------------------------------
-- size
--
-- This returns the size of a key/value pair table. It will also work on arrays,
-- but for arrays it is more efficient to use the # operator.
------------------------------------------------------------------------------------
--]]

function p.size(t)
	checkType('size', 1, t, 'table')
	local i = 0
	for k in pairs(t) do
		i = i + 1
	end
	return i
end


local function defaultKeySort(item1, item2)
	-- "number" < "string", so numbers will be sorted before strings.
	local type1, type2 = type(item1), type(item2)
	if type1 ~= type2 then
		return type1 < type2
	else -- This will fail with table, boolean, function.
		return item1 < item2
	end
end

--[[
	Returns a list of the keys in a table, sorted using either a default
	comparison function or a custom keySort function.
]]
function p.keysToList(t, keySort, checked)
	if not checked then
		checkType('keysToList', 1, t, 'table')
		checkTypeMulti('keysToList', 2, keySort, { 'function', 'boolean', 'nil' })
	end
	
	local list = {}
	local index = 1
	for key, value in pairs(t) do
		list[index] = key
		index = index + 1
	end
	
	if keySort ~= false then
		keySort = type(keySort) == 'function' and keySort or defaultKeySort
		
		table.sort(list, keySort)
	end
	
	return list
end

--[[
	Iterates through a table, with the keys sorted using the keysToList function.
	If there are only numerical keys, sparseIpairs is probably more efficient.
]]
function p.sortedPairs(t, keySort)
	checkType('sortedPairs', 1, t, 'table')
	checkType('sortedPairs', 2, keySort, 'function', true)
	
	local list = p.keysToList(t, keySort, true)
	
	local i = 0
	return function()
		i = i + 1
		local key = list[i]
		if key ~= nil then
			return key, t[key]
		else
			return nil, nil
		end
	end
end

--[[
	Returns true if all keys in the table are consecutive integers starting at 1.
--]]
function p.isArray(t)
	checkType("isArray", 1, t, "table")
	
	local i = 0
	for k, v in pairs(t) do
		i = i + 1
		if t[i] == nil then
			return false
		end
	end
	return true
end

-- { "a", "b", "c" } -> { a = 1, b = 2, c = 3 }
function p.invert(array)
	checkType("invert", 1, array, "table")
	
	local map = {}
	for i, v in ipairs(array) do
		map[v] = i
	end
	
	return map
end

--[[
	{ "a", "b", "c" } -> { ["a"] = true, ["b"] = true, ["c"] = true }
--]]
function p.listToSet(t)
	checkType("listToSet", 1, t, "table")
	
	local set = {}
	for _, item in ipairs(t) do
		set[item] = true
	end
	
	return set
end

--[[
	Recursive deep copy function.
	Preserves identities of subtables.
	
]]
local function _deepCopy(orig, includeMetatable, already_seen)
	-- Stores copies of tables indexed by the original table.
	already_seen = already_seen or {}
	
	local copy = already_seen[orig]
	if copy ~= nil then
		return copy
	end
	
	if type(orig) == 'table' then
		copy = {}
		for orig_key, orig_value in pairs(orig) do
			copy[deepcopy(orig_key, includeMetatable, already_seen)] = deepcopy(orig_value, includeMetatable, already_seen)
		end
		already_seen[orig] = copy
		
		if includeMetatable then
			local mt = getmetatable(orig)
			if mt ~= nil then
				local mt_copy = deepcopy(mt, includeMetatable, already_seen)
				setmetatable(copy, mt_copy)
				already_seen[mt] = mt_copy
			end
		end
	else -- number, string, boolean, etc
		copy = orig
	end
	return copy
end

function p.deepCopy(orig, noMetatable, already_seen)
	checkType("deepCopy", 3, already_seen, "table", true)
	
	return _deepCopy(orig, not noMetatable, already_seen)
end

--[[
	Concatenates all values in the table that are indexed by a number, in order.
	sparseConcat{ a, nil, c, d }  =>  "acd"
	sparseConcat{ nil, b, c, d }  =>  "bcd"
]]
function p.sparseConcat(t, sep, i, j)
	local list = {}
	
	local list_i = 0
	for _, v in p.sparseIpairs(t) do
		list_i = list_i + 1
		list[list_i] = v
	end
	
	return table.concat(list, sep, i, j)
end

--[[
-- This returns the length of a table, or the first integer key n counting from
-- 1 such that t[n + 1] is nil. It is similar to the operator #, but may return
-- a different value when there are gaps in the array portion of the table.
-- Intended to be used on data loaded with mw.loadData. For other tables, use #.
-- Note: #frame.args in frame object always be set to 0, regardless of 
-- the number of unnamed template parameters, so use this function for
-- frame.args.
--]]
function p.length(t)
	local i = 1
	while t[i] ~= nil do
		i = i + 1
	end
	return i - 1
end

function p.inArray(arr, valueToFind)
	checkType("inArray", 1, arr, "table")
	
	-- if valueToFind is nil, error?
	
	for _, v in ipairs(arr) do
		if v == valueToFind then
			return true
		end
	end
	
	return false
end

return p
大便不成形用什么药 心脏超声检查是什么 羊肉炖什么好吃又营养 拔罐后发痒是什么原因 门庭冷落是什么意思
xxx是什么意思 吐信子是什么意思啊 手机什么时候发明的 浅表性胃炎什么症状 流感为什么晚上会比白天严重
臃肿是什么意思 疱疹用什么药好得快 9点半是什么时辰 夏天肚子疼是什么原因 代孕什么意思
126是什么邮箱 解肌是什么意思 尿检蛋白质弱阳性是什么意思 洗牙有什么危害吗 什么是功能性子宫出血
惊蛰是什么意思hcv9jop5ns8r.cn 胎盘埋在什么地方最好hcv9jop4ns9r.cn 二氧化硅是什么晶体hcv8jop0ns8r.cn 血肿是什么意思hlguo.com 不是什么而是什么造句hcv9jop3ns7r.cn
京东plus是什么意思hcv9jop6ns8r.cn 小雪是什么意思hcv7jop9ns8r.cn 甘油三酯低是什么原因hcv8jop4ns4r.cn 什么茶是绿茶hcv8jop0ns2r.cn 申酉是什么时间520myf.com
四大美女指什么生肖hcv8jop5ns9r.cn 什么是过敏体质hcv8jop4ns0r.cn 一天两包烟会导致什么后果hcv8jop1ns7r.cn 什么书最香hcv8jop5ns6r.cn 箨是什么意思hcv8jop0ns9r.cn
公安局大队长是什么级别hcv7jop4ns5r.cn 脱发厉害是什么原因引起的hcv9jop6ns6r.cn polo villae是什么档次yanzhenzixun.com xxoo是什么意思hcv8jop5ns2r.cn 锰酸钾是什么颜色xinjiangjialails.com
百度