月经来了痛经吃什么药| 吃什么东西对胃好| 香港的海是什么海| 川崎病是什么原因引起的| 尿潜血挂什么科| 纯粹什么意思| 闭门思过是什么意思| 兼性厌氧是什么意思| 吃什么治疗湿气重| 妈妈的舅舅叫什么| 心脏下面是什么器官| 妇科彩超主要检查什么| 什么水没有鱼| 莲藕什么时候种植最佳| 世界第一长河是什么河| 吃什么补黄体酮最快| 深水炸弹是什么| 妙赞是什么意思| 竖小拇指什么意思| 腰间盘突出是什么原因引起的| 西红柿对人体有什么好处| zqsg是什么意思| 处女膜在什么位置| 男命正印代表什么| 下火吃什么药| 什么样的西瓜甜| 肝斑一般在脸上的什么地方| 上海玉佛寺求什么最灵验| 潸然泪下是什么意思| 言字旁可念什么| 老年人头晕挂什么科| 什么不得| 居居是什么意思| 下午3点到4点是什么时辰| 仲夏夜是什么意思| cp什么意思网络用语| 生理盐水敷脸有什么效果| 老鼠疮是什么病| 宜五行属什么| 庚是什么意思| 什么病可以请长假| 新生儿什么时候剪头发| 薛定谔的猫比喻什么| 男人人中有痣代表什么| 1992年属什么生肖| 益生菌什么牌子最好| 男人阳萎吃什么药最好| 亲嘴有什么好处| 喝酒眼睛红是什么原因| 陕西的特产有什么| 足石念什么| 一什么雨衣| 525什么星座| 打嗝不停是什么病前兆| 检查是否怀孕要挂什么科| 独生子女证办理需要什么材料| 钾是什么东西| 什么是人设| 碧玺是什么意思| ccu病房什么意思| 体重kg是什么意思| 鱼胶是什么东西| 腹腔淋巴结是什么意思| 陈凯歌为什么不娶倪萍| 蓝颜是什么意思| 肝钙化是什么意思| 发烧应该吃什么药| 5月12号是什么日子| 车前草有什么作用| 地漏什么牌子的好| 阁是什么意思| 既寿永昌什么意思| 女人什么时候停经| 什么降血糖| 白细胞是什么意思| 鸟加一笔是什么字| 坐骨神经痛是什么症状| 办理公证需要什么材料| 多囊性改变是什么意思| 金银花和什么搭配喝好| 什么疲倦| 肿标五项查的是什么| 中气是什么意思| 遗憾是什么| 耳前瘘管有什么危害| 度蜜月什么意思| 今天是个什么日子| 孕妇梦见捡鸡蛋是什么意思| 喜欢绿色的女人是什么性格| 双子男喜欢什么样的女生| 彩虹什么颜色| 检查乙肝挂什么科| 为什么风团会在晚上爆发| 刮痧有什么作用| 履约是什么意思| 贫血吃什么补的快| 小孩子记忆力差是什么原因| 蛀牙是什么原因引起的| 看诊是什么意思| 补血吃什么| 甜菜根在中国叫什么| 身份证上x代表什么| 小腿抽筋是什么原因| 变异性哮喘吃什么药| 身体皮肤痒是什么原因| 糖尿病人吃什么水果| 突然抽搐是什么原因| 益气养阴是什么意思| 鸡犬不宁是什么生肖| 什么病需要化疗| 黄瓜和什么不能一起吃| 嘴唇干燥是什么原因引起的| 啤酒加鸡蛋有什么功效| 台湾什么时候统一| 粳米是什么米| 梦见种树是什么兆头| 肝郁脾虚是什么意思| 障碍是什么意思| 为什么会突然流鼻血| 六月十一是什么星座| 神夫草抑菌乳膏主治什么| 结婚13年是什么婚| 2r是什么意思| 黄芪和什么搭配不上火| 结扎对男人有什么伤害| 癫痫病吃什么药最好| 淋球菌阳性是什么意思| 穷极一生是什么意思| 丢钱是什么预兆| 借什么不用还| 糖尿病人不能吃什么水果| 为什么夏天容易掉头发| 喉咙嘶哑吃什么药| 广州有什么特产| magnesium是什么意思| 牙龈经常发炎是什么原因| 乙肝表面抗原是什么意思| 血脂高吃什么蔬菜好| 蜜枣是什么枣做的| 玻璃心是什么意思| 查肝肾功能挂什么科| 女同学过生日送什么礼物比较好| 高考都考什么| 脚上长水泡是什么原因引起的| 白细胞减少吃什么药| 女性解脲支原体阳性吃什么药| 鲷鱼是什么鱼| 为什么小便是红色的尿| 梦见被狗追是什么意思| 颅内出血有什么症状| mrv是什么检查| 寸头适合什么脸型| 破窗效应是什么意思| 今天冬至吃什么| 嬴稷和嬴政什么关系| 二加一笔是什么字| 奥氮平片治疗什么病| 狂犬疫苗为什么要打五针| 淋巴在什么部位| 男人不举是什么原因造成的| 苹果什么时候出新手机| 血液四项检查是什么| 械字号产品是什么意思| 反酸是什么原因| 一什么点心| 平均血小板体积偏高是什么意思| 1977年是什么年| 洞房是什么意思| 七月18日是什么星座| 九转大肠是什么菜系| 肝实质弥漫性回声改变什么意思| 九寨沟什么时候去最好| 狮子座是什么象| 什么东西止血最快最好| 着凉吃什么药| 为什么越累越胖| 中元节出什么生肖| 狗狗肠胃不好吃什么药最好| 睾丸扭转是什么意思| ahc是韩国什么档次| 肩周炎用什么药最好| 囊肿里面是什么东西| 福祉是什么意思| 天麻加什么治头晕| 莎字五行属什么| 头痛吃什么药最好| 双一流大学是什么| 内痔有什么症状与感觉| 3.1是什么星座| 什么样的女人水多| 吹空调流鼻涕吃什么药| 什么血型会导致不孕| 胸痛什么原因| 劫煞是什么意思| 什么的红烧肉| 无故流鼻血是什么原因| 早餐吃什么最有营养又减肥| 来姨妈吃什么好| 肌酐500多属于什么期怎么治疗| 古代女子成年行什么礼| hpf医学是什么意思| 西洋参泡水喝有什么好处| 老人尿失禁吃什么药最好| 为什么一般不检查小肠| 为什么腰疼| 锁骨是什么骨| 肌肉痛是什么原因| 胃大肚子大是什么原因| 吃什么长得高| 氧氟沙星和诺氟沙星有什么区别| 云南白药的保险子是起什么作用的| 三净肉是什么| 静怡是什么意思| 孤独症有什么表现| 脚掌麻木是什么原因| 文化大革命什么时候结束| 右侧附件区囊性回声是什么意思| 狗和什么属相相冲| 马拉车是什么牌子的包| 肠癌是什么症状| 3月23日是什么星座| 什么球不能踢脑筋急转弯| 做好自己是什么意思| 软坚散结是什么意思| 网球肘是什么症状| 夏天做什么菜| 癸未日五行属什么| 最快的速度是什么| 6月22号是什么星座| 什么是醪糟| 海蛎子是什么| cm代表什么单位| 炎性结节是什么意思| 为什么小腿会抽筋| 梦见死人了是什么预兆| 八月一日是什么节日| 经常喝饮料有什么危害| 尿酸高要吃什么药| 降压药的原理是什么| 姑姑的女儿叫什么| 横行霸道的意思是什么| 鱼能吃什么| 感冒吃什么饭菜比较好| 口咸是什么原因引起的| 膝盖里面痛什么原因引起的| 狼的天敌是什么动物| 荷花和莲花有什么区别| 发烧有什么症状| 周围神经病是什么意思| 骨盐量偏低代表什么| 雯字五行属什么| 骨转移用什么药能治愈| 坐骨神经痛用什么药| 男朋友昵称叫什么好听| 规律是什么意思| 路的尽头是什么| adr是什么激素| 什么的石头| dhc是什么牌子| 阅字五行属什么| 碳14阴性是什么意思| st是什么意思| 榜眼是什么意思| 脂肪燃烧是什么感觉| 百度Presko?i? na obsah

México se une a La Hora del Planeta con apagar luces de monumentos emblemáticos Spanish.xinhuanet.com

z Wikipédie, slobodnej encyklopédie
百度 而在生活中,他则是一位沉稳儒雅的绅士,自律自省,作风老派的老干部。


Túto dokumentáciu [vytvori?] [obnovi?]
Dokumentácia Dokumentácia

Dokumentácia pre tento modul zatia? neexistuje. M??ete ju vytvori? na Modul:TableTools/Dokumentácia


Ak máte otázku k tomuto modulu, alebo potrebujete jeho roz?írenie a neviete ho správne naformátova?, pytajte sa v diskusii k modulu. Pokia? je potrebné modul urgentne opravi?, obrá?te sa na technickú podporu.

--[[
------------------------------------------------------------------------------------
--                               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
四肢无力是什么原因 腊梅什么时候开花 为什么最迷人的最危险是什么歌 1970属什么 大姨妈期间吃什么好
大象吃什么食物 circles是什么意思 为什么总是梦见一个人 卡马西平是什么药 猪大肠炒什么好吃
颈椎挂什么科室 女生是t是什么意思 吃brunch是什么意思啊 促甲状腺激素偏高是什么意思 梦见买鸡蛋是什么意思周公解梦
玉如意什么属相不能戴 过敏性鼻炎吃什么药好 衬衫搭配什么裤子好看 不射精是什么原因 bq是什么意思
ifound是什么牌子hcv9jop6ns3r.cn 92年的猴是什么命hcv8jop0ns9r.cn 男生手淫有什么危害dajiketang.com 脾大是什么病beikeqingting.com 贞洁是什么意思jiuxinfghf.com
2017属什么生肖hcv9jop5ns0r.cn 韧带拉伤有什么症状hcv7jop6ns8r.cn 女生胸痛什么原因hcv9jop4ns7r.cn 眉什么目什么hcv9jop2ns8r.cn 什么不生四字成语hcv7jop9ns2r.cn
新鲜橄榄菜长什么样子hcv7jop5ns0r.cn 梦到别人怀孕是什么意思hcv8jop3ns8r.cn 脑筋急转弯什么东西越洗越脏hcv7jop5ns5r.cn 7月份有什么节日hcv8jop8ns7r.cn 闲云野鹤是什么意思hcv7jop6ns4r.cn
眉骨疼是什么原因hcv9jop5ns4r.cn 唯女子与小人难养也什么意思hcv8jop0ns9r.cn 腮腺炎用什么药yanzhenzixun.com 发烧惊厥是什么症状hcv7jop4ns7r.cn 白起为什么被赐死hcv9jop7ns3r.cn
百度