做脑电图挂什么科| 月子期间可以吃什么水果| 狗吃什么药会立马就死| 尿出红色的尿是什么原因| 喝酒后不能吃什么药| 血糖高有什么症状| 羊眼圈是什么| 淡定自若什么意思| 大便为什么不成形| c12是什么| 维生素b3又叫什么| 阴茎插入阴道什么感觉| 舍是什么结构| 什么人容易得骨肿瘤| 复方氯化钠注射作用是什么| 身体缺钾是什么症状| 阴虚火旺吃什么中药| 小便很黄是什么原因| 晚上睡不着是什么原因| 宝宝拉黑色大便是什么原因| 子宫内膜粘连有什么症状| 吃人参对身体有什么好处| 什么火| 咳嗽应该挂什么科| dpo是什么意思| 猪油用什么容器装好| 每晚做梦是什么原因| 海兔是什么| 为什么可乐能溶解鱼刺| 病机是什么意思| 总出虚汗什么原因怎么解决| 恭喜什么意思| 眼睛里有红血丝是什么原因| 脾切除对身体有什么影响| 刮痧用什么油刮最好| miniso是什么意思| 朴实无华是什么意思| 妄想症有什么症状| 什么人不能喝豆浆| 什么人没有国籍| 为什么说成也萧何败也萧何| leep是什么手术| 肌酸激酶是什么| 杏花是什么季节开的| 心里恶心是什么原因| guess什么意思| 梦见自己大肚子怀孕是什么意思| 解表化湿是什么意思| 荷尔蒙分泌是什么意思| 山川载不动太多悲哀是什么歌| 巨蟹座是什么星象| 列巴是什么| 巫师是什么意思| 什么是长孙| 奇美拉是什么| 什么是假性抑郁症| 突然头晕眼花站不稳是什么原因| 肝右叶钙化灶什么意思| 同归于尽是什么意思| 黑五是什么时候| 121什么意思| 为道日损什么意思| 宝宝大便绿色是什么原因| 冰糖里面为什么有白线| 促甲状腺激素高是什么原因| 刻舟求剑的意思是什么| 怡字五行属什么的| 阑尾炎可以吃什么| 什么会引起高血压| 冬至要注意什么| 舌头发麻是什么病兆| 大便次数少是什么原因| 什么是玫瑰糠疹| 女人吃桑葚有什么好处| 大便特别臭是什么原因| 屑是什么意思| 什么是基础代谢| 阳上人是什么意思| 鸡婆是什么意思| 世交是什么意思| 什么人容易得白塞氏病| 12月23是什么星座| 嘴唇舌头发麻什么病兆| 男戴观音女戴佛是什么意思| 抑郁症是什么病| 梦见小鬼是什么预兆| 什么是植物神经功能紊乱| 口臭严重是什么原因| 吃瓜群众什么意思| 潜血弱阳性是什么意思| 吾矛之利的利什么意思| 肩膀痛挂什么科| 白芷是什么| 彩礼是什么意思| 什么头什么发| 尿检ph值偏高说明什么| 心慌是什么症状| 月经推迟吃什么| 低聚果糖是什么东西| 什么情况下需要做胃镜| 古驰是什么品牌| ala是什么| 什么样的糯米| 十二生肖本领强是什么生肖| 斯里兰卡说什么语言| 牛肉炖什么菜好吃| 高血糖吃什么食物| bpd是什么| 射手座跟什么星座最配| 身上有淤青是什么原因| 什么是中耳炎| 什么什么相什么的成语| 为什么总是想吐| 尿液特别黄是什么原因引起的| 牙龈萎缩吃什么药见效快| 炎细胞是什么意思| 眼角疼是什么原因| 肝阴虚吃什么药| 灵魂伴侣是指什么意思| 麦字五行属什么| 农历六月是什么夏| 手什么眼什么| 八一建军节是什么节日| 痛风不能吃什么东西| 心绞痛有什么症状| 淋巴结清扫是什么意思| 稳重什么意思| 但闻人语响的但是什么意思| 屋漏偏逢连夜雨是什么意思| 经信局是干什么的| 肌肉劳损用什么药| 孩子白细胞高是什么原因| 女人每天喝什么最养颜| 什么是再生障碍性贫血| 脖子出汗多是什么原因女人| 什么是阳虚| 舌根发麻是什么原因| 宝宝舌苔白厚是什么原因| 韬光养晦什么意思| 输卵管堵塞什么症状| 口腔溃疡是缺什么| 韭菜补什么| 毛豆有什么营养价值| pc是什么材料| 非营运车辆是什么意思| 省人大代表是什么级别| 肺部ct能查出什么病| 凤凰代表什么生肖| 盘根是什么| 六味地黄丸适合什么人吃| 缺金的人戴什么最旺| 蒙古族不吃什么肉| 阴囊积液是什么原因引起的| 做梦梦到和别人吵架是什么意思| 口臭药店买什么药吃| 土地兼并是什么意思| 蓝得什么| 八项药是什么药| 八月十日是什么星座| 1945年属什么| 附睾炎是什么原因引起的| 呵呵哒什么意思| 生理期为什么不能拔牙| 争宠是什么意思| 什么是木乃伊| bn是什么意思| 手术后吃什么营养品好| 老是放臭屁是什么原因| 从小一起长大的姐妹叫什么| 尿蛋白两个加号是什么意思| 作灶是什么意思| 鲁米那又叫什么| 红加绿等于什么颜色| 高考用什么笔| 什么是冤亲债主| 熙熙攘攘是什么意思| 折耳根是什么东西| 1994年的狗是什么命| 吗丁啉有什么功效| 手上长汗疱疹用什么药| 什么是党的性质和宗旨的体现| 长期熬夜有什么危害| 尿失禁吃什么药最好| 甲状腺结节吃什么食物好| 肉松可以做什么美食| 乌黑对什么| vans是什么牌子| 低密度脂蛋白高吃什么药| 梦见摘西红柿是什么意思| 牛肉含有什么营养成分| 财政部部长什么级别| 松鼠咬人后为什么会死| 孕妇吃什么补铁| me是什么基团| 为什么女人阴唇会变黑| 归脾丸和健脾丸有什么区别| 冬枣什么时候上市| eva是什么材料| 6月28日什么星座| 蹼是什么意思| 一什么泪珠| 预防脑出血吃什么药| 什么叫相向而行| 晚上睡眠不好有什么办法可以解决| 桉是什么意思| qs是什么| 梦见两个小男孩是什么意思| 常见的贫血一般是缺什么| 脾脏结节一般是什么病| 宫颈纳氏囊肿是什么意思| 满月送孩子什么礼物好| 女人性冷淡吃什么药| 半月板变性是什么意思| 鲁迅是什么样的人| 缺二氧化碳是什么症状| 米非司酮片是什么药| ivy什么意思| 两个虎念什么| 血糖高是什么原因造成的| 甲亢吃什么食物最好| 手胀是什么原因| 社保缴费基数和工资有什么关系| 嗜酸性粒细胞偏高是什么原因| 正高是什么级别| 做春梦是什么原因| 小炒皇是什么菜| cr是什么意思| 宝宝反复发烧是什么原因| 血小板聚集是什么意思| 股骨头坏死什么症状| 吠陀是什么意思| 游戏黑洞是什么意思| 左心室高电压是什么意思| 水钠潴留什么意思| 什么火热| 膏肓是什么意思| 美国是什么人种| 神经官能症挂什么科| ps是什么意思| 经常喝咖啡有什么好处和坏处| 百合和什么搭配最好| 子宫后位什么意思| 面包糠是什么做的| 褥疮用什么药膏最好| 什么是靶向疗法| 六畜兴旺是什么意思| 筑基是什么意思| 美籍华裔是什么意思| 黑色素是什么| 阴道瘙痒吃什么药| 收入是什么意思| 生孩子送什么| 医美是什么意思| 谷字五行属什么| fic是什么意思| 老人身上痒是什么原因| 什么人不能种生基| 感冒了吃什么好的快| 今日冲什么生肖| 减肥期间适合喝什么酒| 天蝎座与什么星座最配| 梦见婆婆去世预示什么| 男人山根有痣代表什么| 更年期吃什么药| 百度Zum Inhalt springen

2017-04-17 12:01:29 NBA 季后赛首轮G1 雷霆vs火箭

Us der alemannische Wikipedia, der freie Dial?kt-Enzyklopedy
百度 超级大的全景天窗、车内氛围灯让爱车秒变爱床,不对是爱巢。

Die Dokumentation für dieses Modul kann unter Modul:TableTools/Doku erstellt werden

--[[
------------------------------------------------------------------------------------
--                               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
嘴唇发白是什么原因引起的 渗透率是什么意思 芋头是什么季节的 玮五行属什么 猴和什么相冲
手麻挂什么科最好 经常叹气是什么原因 广东有什么烟 蚯蚓喜欢吃什么 胸口疼吃什么药
ua医学上是什么意思 尿血吃什么药最好 女人盗汗吃什么好得快 氨气是什么味道 为什么山东人个子高
提单是什么 孕妇吃山竹对胎儿有什么好处 黄花菜长什么样子 衣原体感染男性吃什么药 割包皮有什么影响
晴字五行属什么hcv8jop5ns6r.cn 缺席是什么意思hcv8jop2ns3r.cn 拔了尿管尿不出来有什么好办法hcv8jop9ns0r.cn 手上长小水泡很痒是什么原因zhongyiyatai.com 一树梨花压海棠什么意思hcv9jop6ns3r.cn
空调出现pl是什么意思wuhaiwuya.com 芙蓉是什么hcv9jop6ns9r.cn 招蚊子咬是什么原因hcv8jop6ns5r.cn 烦躁是什么意思hcv9jop0ns3r.cn 1977年属什么生肖hcv8jop2ns0r.cn
绝无仅有的绝什么意思hcv7jop9ns2r.cn 处女座和什么座最配hcv9jop0ns7r.cn 额头冒痘是什么原因hcv8jop0ns0r.cn 轻微脑震荡吃什么药hcv9jop1ns0r.cn 匹马棉是什么面料hcv7jop6ns9r.cn
lover是什么意思hcv9jop0ns5r.cn 发腮是什么意思helloaicloud.com 后会无期什么意思hcv9jop5ns8r.cn 右手臂痛是什么预兆hcv9jop4ns3r.cn 月痨病是什么病hcv9jop8ns3r.cn
百度