什么样的小手| 金融数学学什么| 喝中药尿黄是什么原因| 甲状腺球蛋白高是什么原因| 什么治便秘| 什么是嗳气有何症状| 12.28是什么星座| 冷都男是什么意思| 懊恼是什么意思| sa是什么| 梦见小猫崽是什么意思| 血管瘤有什么危害| 血燥吃什么药| 王八看绿豆是什么意思| 额头上长痘痘是什么原因引起的| 镶牙与种牙有什么区别| cr是什么意思| 病毒感染发烧吃什么药| 来月经量少吃什么可以增加月经量| 复方板蓝根和板蓝根有什么区别| 生化检查能查出什么病| 咳白色泡沫痰吃什么药| m和s是什么意思| 胆结石不能吃什么东西| 腿部抽筋是什么原因引起的| 吃什么对肝好怎么养肝| 清心寡欲下一句是什么| 19属什么| 阴盛阳衰什么意思| 梦见葱是什么意思| 恋爱脑什么意思| 血压高什么症状| 吃什么能降甘油三酯| 胸膜炎吃什么药| 十周年是什么婚| 福鼎白茶属于什么茶| 肝肾挂什么科| iga是什么意思| 占卜什么意思| 蜈蚣长什么样子| 膝盖疼痛用什么药| 为什么不能天天做有氧运动| 考研复试是什么意思| 大肠杆菌吃什么药| 倒三角是什么意思| 五脏是什么| 床虱咬了要擦什么药膏| 肺火大吃什么药| 指甲上有竖条纹是什么原因| 女性痔疮挂什么科室| 黄体破裂什么意思| w是什么单位| 生蚝和什么不能一起吃| 身高用什么单位| 婴儿腹泻吃什么好| 人黄是什么原因| 红玫瑰的花语是什么| 智齿长什么样子图片| 四大美女是什么生肖| 黄芪补什么| 验孕棒什么时候用| 石钟乳是什么| 臀纹不对称有什么影响| 处女座女和什么星座最配| 人的心脏在什么位置| 为什么一紧张就想拉屎| 感情是什么| 命犯桃花是什么意思| 尿沉渣红细胞高是什么原因| 精分是什么| 内务是什么意思| 肝郁血虚吃什么中成药| 循序渐进是什么意思| 莲花代表什么象征意义| 藏毛窦挂什么科| 什么是物理| 属龙跟什么属相最配| 淡蓝色配什么颜色好看| 前列腺钙化灶是什么意思| 幽门螺杆菌抗体阳性什么意思| 血沉高是什么病| 止咳化痰吃什么好| 季夏是什么意思| 移植是什么意思| 脾胃有火是什么症状| 吃什么 长高| 祖字五行属什么| 橄榄枝象征着什么| 看见黄鼠狼有什么预兆| 什么男什么女的成语| 什么样的教诲| 5月10日什么星座| 2035年属什么生肖| 蚱蜢吃什么食物| 艮是什么意思| 25羟基维生素d是什么| 梦到墓地什么预兆| 什么空调最省电| 汞中毒是什么症状| 腹泻肚子疼吃什么药| 朋友过生日送什么好| 石字旁有什么字| 厕所里应该摆什么花| columbia是什么牌子| 病毒性咳嗽吃什么药好| 宫颈粘连什么症状| 武松是什么生肖| 看见蝙蝠有什么预兆| miracle是什么意思| 分山念什么| 漠漠什么意思| 尹是什么意思| 93什么意思| 定海神针是什么意思| 新生儿什么时候可以喝水| 金字旁加各念什么| 什么葡萄品种最好吃| d cup是什么意思| 为什么会长痣| 懒趴是什么意思| 笔走龙蛇是什么生肖| 271是什么意思| hcg是检查什么的| 女人舌苔厚白吃什么药| 什么效应| 四方八面是什么生肖| 人红是非多什么意思| 易激惹是什么意思| 一个火一个日一个立念什么| 筑基期后面是什么| 吃什么补充黄体酮| 腹泻拉稀水是什么原因| 易孕期是什么时候| 9月份是什么星座的| 脚后跟疼用什么药最好| 老年斑长什么样| 盆腔炎用什么药最好| 什么原因导致脑出血| 狮子座是什么象星座| 榴莲为什么会苦| 七月初八是什么星座| 1940年属什么生肖| 低血糖是什么症状| 线索细胞阳性什么意思| 梦见烧衣服什么预兆| 心悸是什么原因引起的| 金色和什么颜色搭配好看| 10月28日什么星座| 十一是什么意思| 什么情况下吃奥司他韦| 手机号码是什么| 婴儿打嗝是什么原因| 自身免疫性肝病是什么意思| 硬水是什么意思| 解脲脲原体阳性是什么| 二级医院什么意思| 三月份生日是什么星座| 尿酸高要注意什么| 正太是什么意思| 左眼皮跳是什么意思| 重庆有什么好大学| 黄曲霉菌是什么颜色| 弃猫效应是什么| 为什么榴莲那么贵| 头发分叉是什么原因| mechrevo是什么牌子的电脑| 小朋友坐飞机需要什么证件| 多多保重是什么生肖| 宫外孕术后可以吃什么| 知乎是干什么的| 以备不时之需什么意思| 长期过敏是什么原因| 子衿是什么意思| 加拿大现在什么季节| 孕妇梦见水是什么意思| 老师的老师叫什么| 腘窝囊肿是什么原因引起的| 吃什么补维生素b| 白细胞高是什么病| 天秤座和什么座最配| 告示是什么意思| 捡和拣有什么区别| 白细胞少会引起什么病| 阳朔有什么好玩的| 渣滓是什么意思| 12月12是什么星座| 什么东西最好卖| 大梁是什么朝代| 奇异是什么意思| 什么是稽留流产| 拉美人是什么人种| 2月12日什么星座| 高半胱氨酸是什么意思| 阴蒂瘙痒是什么原因| 脑内多发缺血灶是什么意思| 点状强回声是什么意思| 眉毛变白是什么原因| 米粉用什么做的| 分野是什么意思| 一个丝一个鸟读什么| 肉烧什么好吃| 上火吃什么消炎药| 血红素高是什么原因| 耳鸣是什么意思| 手机是什么意思| 鱼水之欢是什么意思| 尿多吃什么药| 喉咙有痰是什么原因引起的| 阴阳两虚吃什么食物| 9月30日是什么纪念日| 彩礼什么时候给女方| 为什么总是耳鸣| 享受低保需要什么条件| 附睾炎吃什么药最有效| 男鼠配什么生肖最好| 什么叫钝角| 阿耨多罗三藐三菩提是什么意思| 炙热是什么意思| 孟买血型是什么意思| 做tct检查前要注意什么| 圆脸适合什么镜框| 小龙虾和什么不能一起吃| 甲氨蝶呤是什么药| 什么叫关税| 喝蜂蜜水有什么好处| 豆角不能和什么一起吃| 国印是什么意思| 检查鼻炎要做什么检查| s 是什么意思| 水痘吃什么药| 日语为什么| 肺部纤维灶是什么意思| 肝胆相照是什么意思| 天五行属性是什么| 半枝莲有什么功效| acne是什么意思| 刘邦和刘备是什么关系| 低压偏高是什么原因引起的| 春代表什么生肖| 副歌部分是什么意思| 静候佳音是什么意思| 品牌背书是什么意思| 芙蓉花是什么花| 1950年是什么年| 唱过什么歌| 原汤化原食什么意思| 捞女什么意思| 医生代表什么生肖| 办香港通行证要准备什么材料| 政委是干什么的| 什么是蛋白质| 麦五行属什么| 脑脊液白细胞高是什么原因| 肾积水有什么症状| 放荡不羁爱自由什么意思| 先天性一个肾对人有什么影响| 1946年属什么生肖属相| 唇炎是什么原因引起的| 咨客是做什么的| 三伏天是什么时候开始| 乳腺钙化是什么意思啊| 不靠谱是什么意思| 痛经是什么原因引起的| 粉蒸肉的粉是什么粉| 百度Μετ?βαση στο περιεχ?μενο

李鸿忠张国清段春华盛茂林等参加义务植树活动

Ασ? Βικιπα?δεια
百度   笞杖是中国古代使用得最广泛的刑罚。

Documentation for this module may be created at Module:TableTools/τεκμηρ?ωση

--[[
------------------------------------------------------------------------------------
--                               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
潆是什么意思 热狗为什么叫热狗 生津是什么意思 宠物兔吃什么 气血虚吃什么药
琴代表什么生肖 2005年属鸡的是什么命 三伏天吃什么对身体好 脊柱炎吃什么药 胎儿脉络丛囊肿是什么原因引起的
16周检查什么项目 温吞是什么意思 什么季节补钙效果最好 突然呕吐是什么原因 身心疲惫是什么意思
弦子为什么嫁给李茂 肾阴阳两虚用什么药 万象更新是什么生肖 浑身发热是什么原因 脚脖子抽筋是什么原因
宫腔粘连有什么症状hcv7jop7ns3r.cn 什么样的沙滩dayuxmw.com 无名指长代表什么hcv8jop7ns4r.cn pdr是什么意思hcv9jop4ns0r.cn 蛇与什么属相相克相冲hcv7jop9ns6r.cn
乌龟属于什么动物hcv9jop3ns5r.cn 手足无措的意思是什么hcv9jop0ns6r.cn 肾功能不全吃什么药hcv7jop6ns6r.cn 脖子后面正中间有痣代表什么luyiluode.com 百福骈臻是什么意思520myf.com
泡桐是什么hcv8jop1ns6r.cn 心脏彩超ef是什么意思hcv8jop3ns7r.cn c反应蛋白是什么意思hcv8jop1ns2r.cn 肾虚对男生意味着什么hcv8jop2ns1r.cn 植树节什么时候hcv7jop5ns0r.cn
pef是什么意思xinjiangjialails.com 日值上朔是什么意思hcv9jop5ns4r.cn 金瓜是什么瓜hcv9jop5ns7r.cn 蓝莓葡萄是什么品种imcecn.com 05是什么生肖hcv9jop4ns0r.cn
百度