女性多囊是什么意思| 失眠吃什么药效果好| 早上起床口苦口干是什么原因| 济公是什么生肖| 肺部肿瘤吃什么药| 跃跃欲试什么意思| 酒糟鼻子是什么原因引起的| 白细胞低是什么原因造成的| 什么是机制| 佝偻病什么症状| 胰腺管扩张是什么原因| 春秋是一部什么体史书| 什么人容易长智齿| 11.18是什么星座| 唾液酸苷酶阳性什么意思| 男生被口是什么感觉| 安五行属性是什么| jackjones是什么品牌| 膝盖里面痛什么原因引起的| 风湿免疫科是什么病| 下肢静脉曲张是什么原因引起的| AB型血型有什么优势| 肺部不好有什么症状| 浇去掉三点水读什么| 福利院是干什么的| 但闻人语响的但是什么意思| 前列腺增生是什么原因引起的| 清火喝什么茶| 母亲节送妈妈什么| 王八看绿豆是什么意思| 男孩子什么时候刮胡子| 钥字五行属什么| 牙齿突然酸痛什么原因| 十余年是什么意思| 过奖了是什么意思| 提高免疫力吃什么药| 白酒兑什么饮料最好喝| 脊背疼是什么原因| 豆汁什么味道| 淄博有什么大学| 冲服是什么意思| 碳14阴性是什么意思| 增强ct是什么意思| 汛期什么意思| 夏至是什么| 为什么会有盆腔积液| 来月经可以吃什么水果好| 66年出生属什么生肖| 红棕色是什么颜色| cos代表什么意思| 80岁称什么之年| 知否知否应是绿肥红瘦什么意思| 大便有血是什么原因男性| 肋骨骨折吃什么药| 4月29是什么星座| 胆红素偏高是什么意思| 宫寒是什么原因引起的| bang是什么意思| 阴阳八卦是什么生肖| 红色的菜叫什么| 男女授受不亲是什么意思| 肠炎吃什么食物调理| 肾阳虚吃什么药好| 支原体感染吃什么食物好| 脚后跟干裂是什么原因| 妇检是检查什么| 小肚子疼吃什么药| 冰箱为什么不制冷了| 铺天盖地的意思是什么| 肉桂属于什么茶类| 卫字五行属什么| 国医堂是什么意思| 什么叫混合痔| 盲盒是什么意思| 激凸是什么意思| 血便是什么颜色| 慢性胃炎有什么症状| 安全是什么| 素饺子什么馅儿的好吃| 阑尾在人体的什么位置| 心脏传导阻滞吃什么药| 床上有横梁有什么害处| 常委是什么级别| 心梗吃什么药| 金益什么字| lala是什么意思| 头疼 吃什么药| 79年属羊的是什么命| 宝宝发烧拉肚子是什么原因| 什么是美尼尔氏综合症| 做梦手机坏了什么预兆| coach是什么牌子的包| 吃什么增强免疫力最快| 寸脉弱是什么原因| 例假不能吃什么水果| 扎西德勒是什么意思| 尿糖阳性是什么意思| 99年属兔的是什么命| 梦见下大雪是什么意思| 打鼾是什么意思| 做小月子要注意什么| 胆固醇高有什么症状| 毛五行属什么| 气血不足是什么症状| cif是什么意思| 舌头发涩是什么原因造成的| peter是什么意思| 年抛是什么意思| 手指甲紫色是什么原因| 清道夫鱼为什么不能吃| 咲是什么意思| 6度醋与9度有什么区别| ccf是什么| 老白茶是什么茶| kim是什么意思| 恩师是什么意思| 西红柿和什么榨汁减肥| 口舌是非是什么意思| 吃香蕉有什么好处| 八八年属什么生肖| 疱疹吃什么药可以根治| 因应是什么意思| 抗巨细胞病毒抗体igg高是什么意思| 什么人容易得脑溢血| 卡不当什么意思| 做爱时间短吃什么药好| 戾什么意思| c3是什么意思| 7月16号是什么星座| 补充蛋白质吃什么食物| 烤乳扇是什么| 什么叫皈依| 发烧有什么好处| 金黄色葡萄球菌是什么菌| 掂过碌蔗是什么意思| 1月17号是什么星座| 4月6号什么星座| 乳头痒是怎么回事是什么原因| 怀字五行属什么| 干黄酱是什么酱| 宁的五行属性是什么| 喉咙有浓痰是什么原因| 火疖子是什么| 月泉读什么| 杭州有什么好吃的| 浓绿的什么| 血小板升高是什么原因| 香精是什么| 司法警察是做什么的| 99年是什么年| 吃什么疏通血管| 数不胜数是什么意思| 5月20日是什么日子| 地主是什么意思| 宝宝打嗝是什么原因引起的| 姥姥的妈妈叫什么| 头油是什么原因引起的| 工装裤配什么鞋| 喜欢绿色的女人是什么性格| 慢性胰腺炎吃什么药| nse是什么意思| 梵高属于什么画派| 2022什么年| 一个西一个米念什么| 香港商务签证需要什么条件| 咀嚼什么意思| 脑梗适合吃什么水果| 流感为什么晚上会比白天严重| 维生素k是什么| 耳朵堵塞感是什么原因| 马的贵人是什么生肖| 鲁迅为什么弃医从文| 什么是中位数| 质询是什么意思| 坐骨神经痛是什么原因引起的| 慢性阑尾炎吃什么药好| 四周岁打什么疫苗| 庄周梦蝶是什么意思| 鱼工念什么| 基础油是什么油| 缺钙应该吃什么| 腺肌症吃什么药| 八是什么生肖| 四个一是什么| 什么的孩子| 凭什么是什么意思| 06年属狗的是什么命| 油烟机没有吸力是什么原因| 熬夜吃什么好| 8.11是什么星座| 秦始皇的名字叫什么| 1979年什么命| 脑梗不能吃什么东西| siemens是什么品牌| 一个令一个瓦念什么| 喝黑枸杞有什么作用和功效| 报考军校需要什么条件| 单核细胞是什么意思| 吃什么降血糖最快| 扩招是什么意思| hpv什么症状| 西洋菜俗称叫什么| 胆囊壁毛糙吃什么药效果好| 青少年耳鸣是什么原因引起的| 心肌梗塞是什么症状| 血红蛋白低说明什么| 做妇科检查前需要注意什么| 开平方是什么意思| 大便呈绿色是什么原因| 湿疹是什么样的| 脚后跟疼挂什么科| 妇科臭氧治疗的作用是什么| 声音的传播需要什么| 牙痛什么原因引起的| 85年什么命| 猫不能吃什么东西| 什么星座黑化最吓人| 无花果什么时候结果| 滋阴补肾是什么意思| 扁桃体发炎喉咙痛吃什么药| 打白条是什么意思| 才华横溢是什么意思| 提前吃什么药喝酒不醉| 睡觉喜欢流口水是什么原因| 古代男宠叫什么| 梦见自己怀孕了是什么意思| 健脾祛湿吃什么药| 益生菌什么牌子最好| 什么样的智齿不需要拔| 电疗有什么作用和功效| 地西泮是什么药| 哀莫大于心死什么意思| 爻卦是什么意思| 伊朗用什么语言| 什么叫奢侈| 印第安纹是什么| dl是什么意思| 冶游史是什么意思| 什么药治咳嗽最好| 九品芝麻官是什么级别| 35岁月经量少是什么原因| 婴儿拉肚子是什么原因造成的| 十羊九不全是什么意思| 喝什么茶减肥最有效| 电话停机是什么意思| 硬金是什么意思| 体育生能报什么专业| 什么的森林| 胃炎吃什么食物好养胃| 什么是躯体化症状表现| 阴道有灼热感是什么原因| 案山是什么意思| 怀孕初期怕冷是什么原因| 阳痿什么症状| arg是什么氨基酸| 吃什么能补蛋白| 男性支原体阳性有什么症状| 什么能代替润滑油| 陇是什么意思| 2017年属什么| 高高的什么| 单核细胞百分比偏高是什么意思| 小米粥配什么菜好吃| 眼睛发炎吃什么消炎药| 百度Jump to content

莲都区侨办打通三侨生中考加分“跑零次”服务通道

Ka Wikipedia
百度 人性不可苛求,文明自有温度。

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
阑尾炎看什么科室 instagram是什么意思 梦见自己抬棺材是什么意思 血糖高的人吃什么水果 苏麻为什么不嫁给康熙
胃气不通什么症状 吃什么让月经量增多 境内是什么意思 班禅是什么级别 经常晕倒是什么原因引起的
6月18是什么日子 执业药师是干什么的 天上人间是什么意思 鸡胸挂什么科 什么是五常大米
pro是什么意思 气血不足吃什么药 贾宝玉大名叫什么 眼前有亮光闪是什么问题 黄精什么时候种植
早上起来眼睛肿是什么原因hcv7jop9ns2r.cn 抱大腿什么意思hcv8jop7ns3r.cn 筷子买什么材质的好travellingsim.com 早泄吃什么中药hcv9jop3ns1r.cn 军国主义是什么意思hcv8jop0ns5r.cn
戒指上的s925是什么意思hcv8jop2ns1r.cn 胃穿孔有什么症状hcv7jop5ns4r.cn 飞行员妻子有什么待遇hcv8jop1ns5r.cn 秀才指什么生肖hcv8jop3ns5r.cn 前庭功能检查是查什么cj623037.com
牙疼吃什么消炎药hcv7jop6ns5r.cn 血钾高吃什么药hcv9jop7ns4r.cn ooh什么意思hcv8jop1ns7r.cn 为什么空腹血糖比餐后血糖高hcv9jop6ns9r.cn 枸杞泡茶有什么功效hcv9jop0ns9r.cn
化疗和放疗什么区别hcv8jop3ns7r.cn 夏季吃什么aiwuzhiyu.com 尿酸高要注意什么饮食hcv9jop1ns9r.cn 伊丽莎白雅顿什么档次chuanglingweilai.com 一直咳嗽吃什么药hcv7jop7ns4r.cn
百度