铁蛋白偏高是什么原因| 乌龟喜欢吃什么食物| 预产期是什么意思| 心内科全称叫什么| 什么油炒菜好吃| 深圳副市长什么级别| 贫血吃什么水果好| 不将就什么意思| 心颤吃什么药效果好| 身上有异味是什么原因| 鸡为什么吃自己下的蛋| 胸膜炎是什么症状| 一落千丈是什么生肖| 尿酸高什么不能吃| 芙蓉花又叫什么花| 把碗打碎了有什么征兆| 细菌感染吃什么药| 鼎字五行属什么| 在什么| 血管炎不能吃什么食物| 打封闭针有什么坏处| 每天坚持黄瓜敷脸有什么效果| 二月初九是什么星座| 平均血小板体积低是什么原因| 四面八方指什么生肖| 生理期能吃什么水果| 阿佛洛狄忒是什么神| 什么样的红点是艾滋病| 梦到被狗咬是什么意思| 阑尾疼吃什么药| 夜叉是什么| 甲状腺过氧化物酶抗体高说明什么| 自来卷的头发适合什么发型| 甲状腺属于什么科| 真菌最怕什么| 10月6日是什么星座| dave是什么意思| 血糖高的人吃什么水果| 什么的眉头| 什么饼不能吃| 骁字五行属什么| 经常头晕是什么原因引起的| 咳嗽痰多用什么药| 深喉是什么意思| 眼袋是什么原因造成的| 清华大学什么时候成立| 曹操为什么杀华佗| 火麻仁是什么| 扪是什么意思| 妈妈的爱是什么| 甲午五行属什么| 甲状腺结节有什么症状| 脑出血什么症状| 早上右眼跳是什么预兆| 什么花在春天开| 手心脚心发热是什么原因引起的| 二尖瓣关闭不全是什么意思| 淀粉吃多了有什么危害| 什么是穿刺手术| 乳清粉是什么东西| 正在值机是什么意思| 舌吻是什么| 大人睡觉流口水是什么原因引起的| 单核细胞百分比偏高什么原因| rr医学上什么意思| 回奶什么意思| 34岁属什么的生肖| 什么鸡没有翅膀| 男性尿道刺痛吃什么药| 什么地蹲着| 什么叫五福临门| 屁股右边痛是什么原因| ebv病毒是什么| 吃了虾不能吃什么水果| 脚踝水肿是什么原因| 贫血喝什么口服液最好| 鸟几念什么| 生理期量少是什么原因| 口腔上颚疼是什么原因| 三月初一是什么星座| 市政府秘书长什么级别| 木克什么| 酒精和碘伏有什么区别| 练深蹲有什么好处| 春节吃什么| 拘挛是什么意思| 腿上出汗是什么原因| 坐飞机什么不能带| 尿酸高不能吃什么食物| 脊灰疫苗是预防什么的| 支气管炎咳嗽吃什么药| 意有所指是什么意思| 痢疾是什么| 室上速是什么病| 皮下囊肿挂什么科| 为什么总是做噩梦| 意大利面是用什么做的| 84年属鼠是什么命| 夏天梦见下雪是什么意思| 接吻要注意什么| 血沉高是什么意思| 属龙女和什么属相最配| 一动就出汗吃什么药| 紫外线过敏吃什么药| 晓五行属什么| 猝死是什么意思| 荷花像什么| 益生菌对人体有什么好处| 万马奔腾是什么意思| 为什么姓张的不用说免贵| 杵状指见于什么病| 肉痣长什么样子图片| 传字五行属什么| 实至名归什么意思| 糯米粉可以做什么好吃的| 月经推迟一个月不来什么原因| 迎字五行属什么| 眼睛一直眨是什么原因| 夏天煲什么汤好| 吃什么补血快效果好| 心脏吃什么药最好| 为什么起荨麻疹| 衣冠禽兽指什么生肖| 幽门杆菌的症状是什么| 儿童便秘吃什么最管用| aba是什么意思| 什么神什么注| mg是什么单位| 10.11是什么星座| 化疗期间不能吃什么| 无精打采是什么生肖| 什么器官分泌胰岛素| 送行是什么意思| 4月18号是什么星座| 屈原是什么诗人| 子宫内膜息肉吃什么药| 满江红是什么植物| 1月8号是什么星座| 小孩腰疼是什么原因| 三级手术是什么意思| 补肾壮阳吃什么| 悦五行属什么| 鼎字五行属什么| 包皮龟头炎吃什么药| 运字是什么结构| 肝胆相照是什么意思| 羊水多是什么原因造成的| 贫血吃什么补| 女人辟邪带什么最好| 什么样的生活| 抱薪救火是什么意思| 温字五行属什么| 汉朝后面是什么朝代| 脚面麻木是什么原因| 颈部淋巴结肿大挂什么科| 健字五行属什么| 矬子是什么意思| 自带bgm是什么意思| 月经突然提前一周是什么原因| 胃糜烂吃什么药可以根治| 吃什么护肝| 葡萄是什么茎| 什么中药补肾最好| 什么东西有头无脚| 梦见自己被警察抓了是什么意思| 秦皇岛是什么海| 灰指甲有什么特效药可以治好| 血糖用什么字母表示| 与虎谋皮是什么生肖| 婕妤是什么意思| 胃热吃什么食物好| 什么能减肚子上的脂肪| 禁令是什么意思| 艾滋病潜伏期有什么症状| 什么的树叶| 肝脏低密度灶是什么意思| 三岁属什么生肖| ts是什么意思| 喜欢紫色的女人是什么性格| 什么叫穿刺| 521代表什么含义| 冠脉cta是什么检查| 中管干部是什么级别| 口腔医学技术是干什么的| 梨和什么一起榨汁好喝| 圣诞礼物什么时候送| 中心性肥胖什么意思| 体脂率是什么意思| 86年属虎是什么命| 四川古代叫什么| 荷尔蒙分泌是什么意思| 花椒有什么功效| mbi是什么意思| 早上口干口苦是什么原因| 青椒炒什么好吃又简单| 父亲节应该送什么| 排卵期有什么症状| 家里来狗是什么征兆| 95年猪是什么命| 若无其事的若是什么意思| 肚子疼恶心想吐吃什么药| 扁桃体发炎吃什么药好得快| 为什么排卵期会出血| 小麦淀粉可以做什么| 奎宁是什么药| plano是什么意思| 710是什么意思| 肛门周围痒是什么病| 11.28什么星座| 慢生活是什么意思| 睡着了放屁是什么原因| 口是心非是什么生肖| rr医学上什么意思| 红细胞是什么意思| 低压低有什么危害| 中国中铁是做什么的| 什么时候立冬| 虎落平阳被犬欺是什么生肖| 晚上吃黄瓜有什么好处| 秦朝为什么那么快灭亡| 肝气郁结西医叫什么病| 甘之如饴是什么意思| 跳蚤最怕什么东西| 国潮是什么| 什么而起| 调味茶和茶有什么区别| 吃什么可以变白| 修女是干什么的| 言字旁与什么有关| 球蛋白的功效与作用是什么| 内痔疮用什么药治最好效果最快| 过敏性鼻炎用什么药效果最好| 3个土念什么| 地蛋是什么| 孕晚期为什么会脚肿| 低血糖中医叫什么病| 俊字五行属什么| 丙氨酸氨基转移酶高吃什么药| 五月掉床有什么说法| 饽饽是什么意思| 血府逐瘀丸治什么病| 红细胞偏低是什么意思| 九转大肠是什么菜系| 柠檬泡蜂蜜有什么功效| 情感和感情有什么区别| 父亲节送爸爸什么礼物| 釜底抽薪什么意思| 四月什么星座| 不排卵是什么原因造成| 紫微斗数是什么| 吃什么快速排便| 一吃就吐是什么病症| 吃什么提高免疫力| 金牛座女和什么星座最配| 下午五六点是什么时辰| 扑救带电火灾应选用什么灭火器| 男士私处瘙痒用什么药| 修缮是什么意思| 火焰山为什么这么热| 肺和大肠相表里是什么意思| 女人吃维生素b有什么好处| 淮山跟山药有什么区别| 朋友生日送什么礼物好| 呼吸道感染一般用什么消炎药| 百度Jump to content

新型预备役部队怎么建?火箭军从全国选专家入队

Dae Wikipedia, s'entziclopedia lìbera.
百度 这些变化都与不同社会中的海外华人对“家”这个概念的理解息息相关。

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
新生儿脸上有小红点带白头是什么 手机合约版是什么意思 55岁属什么生肖 女人为什么要少吃鳝鱼 什么样的草地
霖五行属什么 韶字五行属什么 鸡婆什么意思 什么的水井 太多的理由太多的借口是什么歌
tia是什么病 下巴底下长痘痘是什么原因 什么时间入伏 女人喝蜂蜜水有什么好处 京ag6是什么意思
九天什么月 什么样人不能吃海参 吃什么卵泡长得快又好 盐酸哌替啶是什么药 男属龙和什么属相最配
甲状腺双叶回声欠均匀是什么意思hcv9jop5ns6r.cn 维生素b族什么牌子的好fenrenren.com 下葬下雨是什么兆头hcv8jop0ns1r.cn 拉姆是什么意思hcv8jop9ns7r.cn 左侧卵巢无回声是什么意思hcv8jop8ns5r.cn
风雨雷电代表什么生肖dayuxmw.com 抗氧化性是什么意思xinjiangjialails.com 中国在什么半球hcv9jop5ns1r.cn 69什么意思hcv8jop4ns2r.cn 脸色蜡黄是什么原因hcv9jop6ns3r.cn
类风湿不能吃什么食物hcv9jop1ns1r.cn 8月2日是什么星座hcv8jop1ns5r.cn 真菌感染皮肤病用什么药最好gysmod.com 临汾有什么大学hcv8jop5ns7r.cn 高血压看什么科室hcv7jop4ns8r.cn
什么什么不周hcv9jop8ns1r.cn 绘本是什么hcv9jop0ns6r.cn 吃什么对喉咙好mmeoe.com 骑木驴是什么意思hcv8jop5ns9r.cn 办健康证需要带什么证件hcv9jop1ns3r.cn
百度