上眼皮肿了是什么原因| 湿疹是因为什么原因引起的| ccp抗体是什么意思| 饿了手抖是什么原因| 东南大学什么专业最牛| 什么的太阳| 嗓子有黄痰是什么原因| 晟是什么字| 阴道出血吃什么药| 什么的春天| 三条杠是什么牌子| 心肌病是什么病严重吗| 槐树什么时候开花| 颏下是什么部位| 雄性激素过高是什么原因| 马兰头是什么菜| 舌头上有黑点是什么原因| 胃胀想吐吃什么药| 眼皮有痣代表什么| 三级士官是什么级别| 出大汗是什么原因| 右腹疼是什么原因| 喉咙发炎吃什么水果好| 补血补气吃什么最快最好| 手指甲发白是什么原因| 雪茄是什么| 糜烂性胃炎有什么症状| 男性生殖长水泡是什么原因| 苦海翻起爱恨是什么歌| 天热吃什么| 乳糖不耐受喝什么奶粉比较好| 蛋白粉有什么功效| 什么都不怕| 脚底板脱皮是什么原因| 胃不好吃什么药| 菠萝蜜不能跟什么一起吃| 喝茶叶茶有什么好处| 心律失常是什么意思| 阴差阳错是什么意思| 起早贪黑是什么生肖| 公历是什么历| 腿麻是什么病的前兆吗| 葳蕤是什么意思| 孕妇感冒了可以吃什么药| 喝酒不能吃什么水果| 月经每次都推迟是什么原因| 下巴肿大是什么原因| 煜字五行属什么| 胆固醇偏高有什么危害| 什么是什么意思| 柔顺剂是什么| 巫是什么意思| 活色生香什么意思| 为什么相爱的人却不能在一起| 鹅喜欢吃什么食物| 庚子五行属什么| 膝盖肿是什么原因| 轻奢是什么意思| 打摆子是什么病| 血漏是什么病| 从容不迫什么意思| 眼睛有痣代表什么| 感冒去医院挂什么科| 呔是什么意思| 木加一笔有什么字| 沙门氏菌用什么药| mr是什么意思| hj是什么意思| 家的意义是什么| 保险费率是什么| 胰腺炎吃什么药好| 一是什么动物| 活色生香什么意思| 脑梗需要注意什么| 醋加小苏打有什么作用| 青蒿素是什么| 一什么月牙| 氟康唑治什么妇科炎症| 脾虚有什么症状| 降尿酸什么药最好| 视角是什么意思| 宁属于五行属什么| 周围神经病是什么病| 津液是什么| uspa是什么牌子| 人为什么不可以偏食| 什么牌子的益生菌调理肠胃比较好| 什么的雪莲| 经方是什么意思| 橘子什么时候成熟| kcl是什么药| 为什么喝酒后会头疼| 叶黄素是什么| 4月20日什么星座| 虚情假意是什么意思| 镜子是什么生肖| 吃降压药有什么副作用| 澳门什么时候回归的| 3.19号是什么星座| 失物招领是什么意思| 外阴白斑是什么原因| 旁支是什么意思| 身上长红痣是什么原因| 挖空细胞是什么意思啊| 随喜功德是什么意思| 对联又称什么| 有氧运动什么意思| 莲雾是什么| 甲功三项是什么| 武昌鱼是什么鱼| adidas是什么品牌| 没有美瞳护理液用什么代替| 农历5月20日是什么星座| 小受是什么意思| 春天是什么颜色的| 宫后积液是什么意思| 77属什么生肖| 诺如病毒吃什么食物| 直系亲属为什么不能输血| 网络诈骗打什么电话| 10月13号是什么星座| 准妈妈是什么意思| 缺如是什么意思| 男扮女装叫什么| 高血压挂什么科| 七月十九是什么星座| 术后改变是什么意思| 反复口腔溃疡是什么原因| 千里马比喻什么样的人| 三个羊念什么| 结婚13年是什么婚| 后中长是什么意思| 海参崴买什么便宜| 感光度是什么意思| 保家仙是什么| 胃潴留是什么病| 妈妈的爸爸叫什么| 碍事是什么意思| 低血糖会出现什么症状| 重庆房价为什么这么低| 肌无力是什么症状| 芈怎么读什么意思| 风湿是什么原因引起的| 人中跳动是什么原因| 检查梅毒挂什么科| 吃什么食物补铁| 红色学士服是什么学位| 打呼噜是什么原因造成的| vivo手机是什么牌子| fla是什么牌子| 乌鸡不能和什么一起吃| 呕吐是什么原因引起的| 柿子什么时候成熟| 便民门诊是做什么的| 麦的部首是什么| 水肿是什么意思| 甲状腺彩超挂什么科| 今晚开什么特马| 辞海是什么书| 窍是什么意思| 怀孕10多天有什么症状| 青梅是什么水果| 夏令时什么时候开始和结束| 胆红素升高是什么原因| 轶字五行属什么| 什么样的阳光填形容词| 射的快吃什么药| 来日方长什么意思| 黑枸杞泡水喝有什么作用和功效| 低血压高什么原因| 角的大小和什么有关| 瑗字五行属什么| 拒服兵役是什么意思| 视网膜病变有什么症状| 田螺吃什么食物| 二月二十是什么星座| 大便前面硬后面稀是什么原因| 体力不支是什么意思| 一进去就射是什么原因| 父亲节送什么礼物比较好| 什么是邮箱地址应该怎么填写| 牙齿出血是什么病征兆| 染色体由什么和什么组成| 身高用什么单位| 左手小指和无名指发麻是什么原因| 月字五行属什么| handmade是什么牌子| 乳酸脱氢酶高是什么原因| pr过高是什么意思| 晕车吃什么好| 很man是什么意思| 为什么睡不着觉会胡思乱想| 济南为什么叫泉城| 枸杞补什么| 阴毛有什么用| 智商125是什么水平| 欲言又止是什么意思| 1970属什么| 小孩口腔溃疡吃什么药| 妇科养荣胶囊主治什么| 蟑螂对人体有什么危害| 女人骨质疏松吃什么最好| 脖子疼是什么原因引起的| 嘴麻是什么原因| 不悔梦归处只恨太匆匆是什么意思| hm是什么| 儿童结膜炎用什么眼药水| 尿道炎吃什么消炎药| 梦见粉条是什么意思| 什么手机拍照好看| 姓卢的男孩起什么名字好| 内痔吃什么药| 什么魂什么魄| 3.25是什么星座| 割掉胆对人有什么影响| 指甲表面凹凸不平是什么原因| 四月十五日是什么日子| tim是什么| 赤潮是什么意思| 读军校需要什么条件| 三叶香是什么菜| 不打紧是什么意思| 剥苔舌是什么原因| 考教师资格证需要什么条件| 吴字五行属什么| galaxy是什么牌子| 口腔检查挂什么科| 阿拉蕾什么意思| 肾积水有什么危害| 咳血是什么病| 为什么胸闷一吃丹参滴丸就好| 糖类抗原50是什么指标| eb病毒阳性是什么意思| 四川人为什么喜欢吃辣| ercp是什么| 平反是什么意思| 什么是佛| 滚去掉三点水念什么| 阴虱用什么药物| lino是什么面料| 来月经为什么会拉肚子| 7.14是什么日子| spa是什么意思| 煎牛排用什么油| 荔枝和什么不能一起吃| 尿hcg阳性是什么意思| 上不下要念什么| 神经紊乱吃什么药| 枸杞与菊花一起泡水喝有什么功效| 什么样的房子风水好| 派对是什么意思| 不感冒是什么意思| 三点水加个及念什么| 为什么喝咖啡会心慌| 杨梅有什么功效与作用| 环比是什么意思| kpi什么意思| 呕吐是什么原因| 黄色五行属什么| 长的像蛇的鱼是什么鱼| 眼睛为什么会痛| 俄罗斯特工组织叫什么| 小暑是什么意思啊| 三伏贴什么时候贴| 百度Μετ?βαση στο περιεχ?μενο

互联网金融监测情况报告:新增收录1189家互金平台

Απ? τη Βικιπα?δεια, την ελε?θερη εγκυκλοπα?δεια

--[[
------------------------------------------------------------------------------------
--                               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
女人的秘密是什么 为什么科比叫黑曼巴 酸奶可以做什么美食 儿童流鼻涕吃什么药 气管炎吃什么好
钾低是什么原因造成的 地贫和贫血有什么区别 极光是什么 青海有什么好玩的 什么效应
什么样的脸型有福 梦见自己拉了很多屎是什么意思 被隐翅虫咬了用什么药 男人阳气不足有什么症状 头出虚汗是什么原因引起的
肝功能检查什么 中央委员什么级别 小孩咳嗽流鼻涕吃什么药效果好 脂溢性脱发用什么洗发水 大肝功能是检查什么
梦见牙碎了是什么预兆hcv8jop5ns6r.cn 新鲜的乌梅长什么样aiwuzhiyu.com 什么是工作hcv8jop5ns4r.cn 受委屈是什么意思hcv9jop5ns3r.cn 27岁属什么生肖hcv9jop2ns1r.cn
c反应蛋白是什么hcv7jop6ns4r.cn 白白的云朵像什么hcv7jop9ns9r.cn 老年人嘴唇发紫是什么原因hcv9jop2ns1r.cn 腰椎盘突出挂什么科gysmod.com 财神在什么方位hcv9jop1ns9r.cn
s倾向是什么意思hcv7jop6ns7r.cn 黄柏泡水喝有什么功效hcv8jop2ns6r.cn 天麻能治什么病hcv8jop2ns1r.cn 经常自言自语是什么原因hcv8jop1ns9r.cn 土豆不能和什么一起吃hcv9jop5ns9r.cn
肝脓肿是什么病严重吗hcv9jop6ns7r.cn 不加一笔是什么字hcv9jop6ns9r.cn 顾名思义的顾什么意思helloaicloud.com 榴莲坏了是什么味道naasee.com 阴虚是什么意思hcv7jop7ns3r.cn
百度