附子理中丸治什么病| 胆碱酯酶低是什么原因| 经常做梦是什么原因| dave是什么意思| 眼睑痉挛挂什么科| 多动症挂什么科| 一什么一什么| 支原体弱阳性是什么意思| 白羊座上升星座是什么| 四面八方什么生肖| o型血的人是什么性格| 姓林的女孩取什么名字好| 一个月一个泉是什么字| 流局是什么意思| 日新月异是什么意思| 癌抗原125是什么意思| 奥美拉唑与雷贝拉唑有什么区别| 2016年是什么命| 秋葵是什么| 骨髓瘤是什么原因引起的| 舌炎是什么原因引起的怎样治疗| 狗皮膏药什么意思| 什么是ppi| 非钙化斑块是什么意思| 谷丙转氨酶高是什么原因| 樱桃有什么营养| 六亲缘浅是什么意思| 盐酸多西环素片治什么病| 喷塑工是干什么的| 什么至什么来| 皋读什么| 复姓是什么意思| 毫不逊色的意思是什么| 男性裆部瘙痒用什么药好| 维生素b2是什么| 营长是什么军衔| 雀神是什么意思| 过敏性结膜炎用什么药| 珍母口服液有什么作用| 阴道里面痒是什么原因| 查肝挂什么科| 飞蛾为什么会扑火| 舌根部淋巴滤泡增生吃什么药| green是什么颜色| 牙龈发紫是什么原因| 巨细胞病毒阳性什么意思| 痛风喝酒会有什么后果| 什么花走着开| 手脚肿胀是什么原因引起的| 做肠镜要挂什么科| 浑身没力气是什么原因| kenzo是什么牌子| 照影是什么检查| 吃什么增加卵泡| 接风吃什么| 红玫瑰花语是什么意思| 矽肺是什么意思| 下肢静脉血栓吃什么药| 吴京为什么看上谢楠| 什么眉头| 胆固醇高吃什么药| 女生隐私长什么样| 造影是什么意思| 肠澼是什么意思| 梦魇是什么原因造成的| 陈皮有什么功效作用| 不期而遇什么意思| 锄禾是什么意思| 日丙念什么| 老年斑长什么样| mixblu是什么牌子| showroom是什么意思| 眼睛变红了是什么原因| 电轴左偏是什么原因| 斐乐手表属于什么档次| 什么是朱砂痣| 胎儿右肾盂分离是什么意思| 幽门螺旋杆菌抗体阳性是什么意思| 为什么姨妈迟迟不来| 液金是什么| 左脚麻是什么原因| 口臭吃什么药效果最好| 开封菜是什么意思| 中国最厉害的武器是什么| 异常脑电图说明什么| 百香果配什么好喝| 八格牙路是什么意思| 喝冰糖水有什么好处和坏处| 世界上有什么| 阴道息肉长什么样| 白头发吃什么能变黑| 通字五行属什么| 绛紫色是什么颜色| 鱼能吃什么| 放臭屁吃什么药| 翻糖蛋糕是什么意思| 鲍温病是什么病| 定妆用什么好| 三周年祭日有什么讲究| 吃虾不能吃什么| 高凝状态是什么意思| azul是什么颜色| 芦荟胶有什么用| 不到长城非好汉的下一句是什么| 拾荒者是什么意思| 汗是什么味道| 血气方刚什么意思| 烫伤挂什么科室| 为什么正骨后几天越来越疼| 单位工会主席是什么级别| 披靡是什么意思| 小便是红色的是什么原因男性| 府尹相当于现在什么官| 神经性皮炎用什么药膏| cim是什么意思| 金不换是什么意思| 司命星君掌管什么| 胆红素偏高是什么原因| 10.16是什么星座| 杨梅是什么季节的水果| o2o什么意思| 为什么会有地震| 律的右边读什么| 茯苓泡水喝有什么功效| 6月28日是什么日子| 长期胃胀是什么原因| 三星堆为什么叫三星堆| 什么是生化妊娠| 什么是三有保护动物| 胃食管反流挂什么科| 什么是气胸有什么症状| 1月18日什么星座| vertu手机为什么那么贵| 熬夜有什么危害| 呕吐腹泻是什么原因| gmv是什么意思| 室颤是什么意思| 育婴员是做什么的| 痰多吃什么药| 风湿性关节炎什么症状| 头晕是什么病的征兆| 见人说人话见鬼说鬼话是什么意思| 超拔是什么意思| 头晕有点恶心是什么原因| 戌时属什么生肖| 桃子又什么又什么| 软组织挫伤是什么意思| 手机越狱什么意思| 耳朵为什么老是痒| 荨麻疹吃什么药最有效| 6月份生日是什么星座| 数据中心是什么| 喝酒对身体有什么好处和坏处| 米咖色是什么颜色| 飞蛾吃什么| 满城尽带黄金甲是什么意思| 肌腱是什么组织| 什么什么的田野| 手指尖疼是什么原因| 斜杠青年什么意思| 什么体质容易长结石| 床单什么颜色有助于睡眠| 总警司相当于大陆什么官| 考军校要什么条件| 女子与小人难养也什么意思| 大腿根疼挂什么科| 夏天种什么水果| 神经性头痛吃什么药效果好| 刀口力念什么| 你的名字讲的什么故事| 急性胰腺炎吃什么药| 为什么要割包皮| 睡不着觉是什么原因| 爽是什么结构| 儿童个子矮小看什么科| 被舔下面什么感觉| 消化不良反酸吃什么药| 董监高是什么意思| 脚肿腿肿是什么原因引起的| 肌酐什么意思| 玫瑰痤疮是什么原因| ace什么意思| 吃黄瓜有什么好处| 宫颈轻糜是什么意思| 燕子每年从什么方飞往什么方过冬| 迪根是什么药| 典韦字什么| 高胰岛素血症是什么病| 鼻干眼干口干属于什么症状| 水球是什么| 7月26日什么星座| 暗网是什么| 灬是什么意思| 辟支佛是什么意思| 越五行属性是什么| 丑时是什么时候| 蒙古古代叫什么| 口若悬河是什么意思| 兵解是什么意思| 女性头部出汗吃什么药| 什么来钱快| 射手座属于什么象星座| 洗耳恭听什么意思| 2034年是什么年| 行政助理是干什么的| 彩超低回声是什么意思| 东北和山东有什么区别| 意象是什么| 做全身检查挂什么科| 土豆不能和什么一起吃| 纪委是做什么的| 花生属于什么类食物| 房性早搏是什么意思| as材质是什么材料| 什么叫化疗| 梅花在什么季节开放| 725是什么意思| 风指什么生肖| 痤疮用什么药治最好效果最快| 漂洗是什么意思| 姓叶的男孩取什么名字好| 女孩和女人有什么区别| 茯苓有什么功效和作用| 甲沟炎涂抹什么药膏最有效| 与五行属什么| 枫叶的花语是什么| 差强人意是什么意思| 什么虫子咬了会起水泡| 善太息是什么意思| 混合型高脂血症是什么意思| 人流复查做什么检查| 齐多夫定片是治什么病的| 股票解禁是什么意思| 7月15是什么星座的| 公务员是什么编制| 什么是脉冲| 宝宝尿少是什么原因| 哈利波特是什么意思| 生不如死什么意思| 大头菜是什么菜| 肺气虚吃什么食物| 为什么会一直流鼻涕| 三七粉什么时间喝好| 又什么又什么| 桑葚泡水喝有什么功效| 兵解是什么意思| 高血压药什么时候吃最好| 胃溃疡a2期是什么意思| 114514是什么梗| 什么血型招蚊子叮咬| 脂肪瘤吃什么药可以消除| 肋骨骨折挂什么科| 人格是什么| 鼻子经常流鼻涕是什么原因| 六月二十八是什么日子| 尖锐湿疣的症状是什么| 今天的日子适合做什么| 一月四号是什么星座| 眼皮为什么会跳| 什么是生命之本| 排尿困难是什么原因男性| 慢性咽炎吃什么药效果最好| 撕脱性骨折什么意思| 李连杰是什么国籍| 百度Zum Inhalt springen

告别家里电线乱插乱放 全屋开关插座布置攻略

Ord Wikipedia
百度   卢柯认为,科学研究是兴趣驱动的学习过程,是一种精益求精、追求完美的艺术,理想是科学研究的重要动力。

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
放疗后吃什么恢复快 刺梨是什么 豆泡是什么 1月19日什么星座 用淘米水洗脸有什么好处
己巳五行属什么 人工流产后可以吃什么 10月9号是什么星座 付诸行动是什么意思 胡麻是什么
米黄是什么颜色 cr是什么意思 中文是什么意思 风波是什么意思 乙肝病毒表面抗体弱阳性什么意思
棕色用什么颜色调出来 深水炸弹是什么 12583是什么电话 嗓子痛什么原因 上火吃什么最快能降火
看脊椎挂什么科hcv8jop4ns6r.cn 五金店卖什么xinmaowt.com 米杏色是什么颜色hcv7jop6ns9r.cn 爱是什么偏旁hcv8jop7ns7r.cn 什么是三宝hcv8jop9ns7r.cn
什么的微风填空hcv9jop6ns9r.cn 骨头咔咔响是什么原因hcv8jop3ns5r.cn 员级职称是什么意思hcv9jop4ns1r.cn 游龙斑是什么鱼hcv7jop9ns9r.cn 颔是什么意思hcv8jop3ns5r.cn
豆汁是什么hcv7jop9ns7r.cn 油是什么意思hcv8jop7ns7r.cn 刺激性干咳是什么症状kuyehao.com 风度是什么意思hcv7jop6ns5r.cn va是什么维生素hcv8jop5ns0r.cn
玉字是什么结构hcv9jop6ns6r.cn 痈疡是什么意思hcv8jop4ns7r.cn 体毛多是什么原因yanzhenzixun.com 胃烧心吃什么能缓解hcv8jop3ns6r.cn 沉淀是什么意思jiuxinfghf.com
百度