男人更年期在什么年龄| 剖腹产吃什么下奶快| 睡觉被口水呛醒是什么原因| 什么人什么目| 为什么会气血不足| 人中跳动是什么原因| 喝什么茶养肝护肝排毒| 4月15日是什么日子| 今夕何夕是什么意思| 反流性食管炎吃什么药最好| 68岁属什么| 孕酮低吃什么补得快| 屁多屁臭是什么原因| 外痔疮有什么症状| 什么龙什么凤| 嗳气是什么原因| 硬不起来吃什么药| 心火旺吃什么中药| 中国发明了什么| 肝有钙化灶是什么意思| 小孩吃什么能长高| 胃大肚子大是什么原因| 请什么自什么| 眼睛发热是什么原因| b3是什么维生素| 孽障是什么意思| 慢性鼻窦炎吃什么药| 樵夫是什么生肖| 结婚55周年是什么婚| 例假来的是黑色的是什么原因| 晨跑有什么好处| 门口放镜子有什么讲究| 心脏属于什么系统| apn是什么意思| 女人戴什么招财又旺夫| 什么啊| 人潮涌动是什么意思| 全糖是什么意思| 摩羯座是什么象| 忠字五行属什么| 咳绿痰是什么原因| 心脏不好挂什么科| 节点是什么意思| heineken是什么啤酒| 什么是留守儿童| 尾巴骨疼挂什么科| 薜丁山是什么生肖| 因人而异是什么意思| 婴儿为什么戴银不戴金| 心脏回流是什么意思| 腐败什么意思| 猪血炒什么好吃| 孩子脾虚内热大便干吃什么药| dna里面有什么| rh是什么血型| ab型血和b型血生的孩子是什么血型| 五毒是什么| 脸上有红血丝是什么原因| 4月3号什么星座| 为什么一吃辣的就拉肚子| 口腔溃疡用什么药治疗| 尿培养是检查什么病| 月经9天了还没干净是什么原因| 割包皮属于什么科室| ct腹部平扫能检查什么| 籍贯是指什么| 茄子和什么不能一起吃| 做梦飞起来了是什么兆头| 什么样的女人最吸引男人| 舌根发黄是什么原因造成的| 尿比重偏高是什么原因| 常熟有什么好玩的地方| 胡麻是什么| 奶油奶酪可以做什么| 湿气重有什么症状| 低压高什么原因| 夏天做什么菜| 六月下旬是什么时候| 纸尿裤nb是什么码| 羊和什么属相最配| 散瞳是什么意思| 室早是什么意思| 画面感是什么意思| 名人轶事是什么意思| 三原色是什么| 大黄是什么药材| 拉黑粑粑是什么原因啊| 二尾子什么意思| 马来西亚人为什么会说中文| 一个至一个秦是什么字| 吃激素有什么副作用| 精忠报国是什么意思| 处女膜什么样子| 弱不禁风是什么生肖| 梦到别人怀孕是什么意思| 鸡拉白色稀粪吃什么药| 推荐是什么意思| 姐夫的爸爸叫什么| 适合什么发型| 鼻甲肥大是什么原因| 怀孕初期头晕是什么原因| 十一月二十二是什么星座| 梦见金项链是什么意思| 丘比特是什么意思| 梦见新房子是什么意思| 鼻子和嘴巴连接的地方叫什么| 建卡需要带什么证件| 咽炎吃什么消炎药最好| 身上长白点是什么原因| 胎动什么时候出现| 脊髓损伤有什么症状| 全期猫粮什么意思| 桃胶什么时候采摘最好| rice什么意思| 梦见亲人死了是什么意思| 什么是粗粮| 佩戴沉香有什么好处| 薜丁山是什么生肖| 扑街什么意思| 阴道瘙痒用什么药最好| 遗传代谢病是什么意思| 城镇户口是什么意思| 董事总经理是什么职位| 黄芪和什么泡水壮阳| 6月13日是什么星座| 母螳螂为什么要吃公螳螂| 十月一日什么星座| 3月份出生是什么星座| 对口升学什么意思| 777什么意思| 疣长什么样| 什么的看| 刘嘉玲什么星座| jeep是什么牌子| 女方什么人不能送亲| 太阳最后会变成什么| 牙龈萎缩是什么原因造成的| 戴尾戒是什么意思| 四十不惑是什么意思| 梅花手表属于什么档次| handmade是什么牌子| a型rh阳性是什么意思| 黑无常叫什么| 千什么一发| 历时是什么意思| 八月十四是什么星座| 鱼油对身体有什么好处| 什么是阴阳| 赵云的坐骑是什么马| 618是什么节日| 指甲花学名叫什么| 胃疼肚子疼是什么原因| 胎教什么时候开始最好| 脑血栓不能吃什么水果| soda是什么意思| 6月2日是什么星座| 雉是什么动物| 什么水晶招财| ur是什么缩写| 抗甲状腺球蛋白抗体高是什么意思| 发达国家的标准是什么| 大肠杆菌属于什么菌| 什么叫血沉| 同化是什么意思| 有什么四字词语| 荨麻疹吃什么药好得快| 盲肠憩室是什么意思| 减肥期间应该吃什么| 窦性早搏是什么意思| 什么颜色的猫最旺财| 什么是灰指甲| 晏字五行属什么的| 木梳子梳头有什么好处| 粉荷花的花语是什么| 汗毛重是什么原因| 你想什么| 血糖高可以吃什么主食| 人突然瘦了要检查什么| 犹太人为什么那么聪明| 什么是排卵期怎么计算| 吃什么尿酸降得快| 排卵期有什么感觉| 被螨虫咬了非常痒用什么药膏好| 什么是心脑血管疾病| 筒骨炖什么好吃| waist是什么意思| spc是什么意思| 昱这个字念什么| 海参什么时间吃最好| 安抚奶嘴什么时候开始用| 什么吃草吞吞吐吐歇后语| 盆腔镜检查是查什么的| 顶胯是什么意思| 血液病是什么| 肩胛骨突出是什么原因| 肌瘤和囊肿有什么区别| 吃什么能软化血管| 什么是bg| 子衿是什么意思| 脖子长小肉粒是什么原因| 割包皮有什么用| 唐伯虎是什么生肖| 黑胡桃色是什么颜色| 卵巢过度刺激综合症是什么| 卧蚕是什么意思| 小孩肚子痛吃什么药| 为什么吃火龙果会拉肚子| 菠萝与凤梨有什么区别| 转头头晕是什么原因| 海为什么是蓝色的| 开方是什么意思| 男票是什么意思| 意大利用的什么货币| petct是什么检查| 莲子有什么作用| 口炎读什么| 什么地方| nba下个赛季什么时候开始| 1月2日什么星座| 右眼睛跳是什么预兆| 杏仁有什么作用和功效| 3月9号是什么星座| 井代表什么生肖| 列席人员什么意思| 醒酒器有什么作用| 查血糖是什么检查项目| 二尖瓣反流是什么意思| 甘油三酯高是什么原因造成的| 灾煞是什么意思| 月经不停吃什么药止血效果比较好| 做梦吃屎有什么预兆| 早孕期间吃什么最营养| 感冒吃什么| 郁金香长什么样子| 血热吃什么中成药| 牡丹王是什么茶| 黄疸吃什么药| 眼睛长结石是什么原因引起的| 六月六吃什么| 来例假腰疼是什么原因| 海鸥吃什么| 丝瓜配什么炒好吃| 什么什么二什么成语| 老公工作劳累炖什么汤| 石灰水是什么| 今年是农历的什么年| 五四运动的精神是什么| 大学校长什么级别| 氯雷他定不能和什么药一起吃| 电焊打眼最有效最快的方法是什么| 宝宝拉肚子吃什么药| 腰花是什么部位| 什么水果补气血| 结肠炎有什么症状| 发烧输液输的是什么药| 女性朋友生日送什么礼物好| 2018年属什么| 酮症酸中毒什么原因引起的| 浮瓜沉李什么意思| min是什么| 市政府办公室主任是什么级别| 被蜜蜂蛰了有什么好处| 什么是童话| 1962属什么生肖| 百度Ugrás a tartalomhoz

U23的年轻人 拼的不是命,是命令

Ellen?rz?tt
A Wikipédiából, a szabad enciklopédiából

TableTools[mi ez?] ? [dokumentáció: mutat, szerkeszt] ? [tesztek: létrehozás]

------------------------------------------------------------------------------------
--                                   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)
	return type(v) == 'number' and v >= 1 and floor(v) == v and v < infinity
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)
	return type(v) == 'number' and v ~= v
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)
	checkType('shallowClone', 1, t, 'table')
	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(arr)
	checkType('removeDuplicates', 1, arr, 'table')
	local isNan = p.isNan
	local ret, exists = {}, {}
	for _, v in ipairs(arr) 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 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.
		return s:gsub('([%(%)%%%.%[%]%*%+%-%?%^%$])', '%%%1')
	end

	prefix = prefix or ''
	suffix = suffix or ''
	prefix = cleanPattern(prefix)
	suffix = cleanPattern(suffix)
	local pattern = '^' .. prefix .. '([1-9]%d*)' .. suffix .. '$'

	local nums = {}
	for k 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 _ 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
	elseif type1 == 'table' or type1 == 'boolean' or type1 == 'function' then
		return tostring(item1) < tostring(item2)
	else
		return item1 < item2
	end
end
------------------------------------------------------------------------------------
-- keysToList
--
-- Returns an array 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 arr = {}
	local index = 1
	for k in pairs(t) do
		arr[index] = k
		index = index + 1
	end

	if keySort ~= false then
		keySort = type(keySort) == 'function' and keySort or defaultKeySort
		table.sort(arr, keySort)
	end

	return arr
end

------------------------------------------------------------------------------------
-- sortedPairs
--
-- 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 arr = p.keysToList(t, keySort, true)

	local i = 0
	return function ()
		i = i + 1
		local key = arr[i]
		if key ~= nil then
			return key, t[key]
		else
			return nil, nil
		end
	end
end

------------------------------------------------------------------------------------
-- isArray
--
-- Returns true if the given value is a table and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArray(v)
	if type(v) ~= 'table' then
		return false
	end
	local i = 0
	for _ in pairs(v) do
		i = i + 1
		if v[i] == nil then
			return false
		end
	end
	return true
end

------------------------------------------------------------------------------------
-- isArrayLike
--
-- Returns true if the given value is iterable and all keys are consecutive
-- integers starting at 1.
------------------------------------------------------------------------------------
function p.isArrayLike(v)
	if not pcall(pairs, v) then
		return false
	end
	local i = 0
	for _ in pairs(v) do
		i = i + 1
		if v[i] == nil then
			return false
		end
	end
	return true
end

------------------------------------------------------------------------------------
-- invert
--
-- Transposes the keys and values in an array. For example, {"a", "b", "c"} ->
-- {a = 1, b = 2, c = 3}. Duplicates are not supported (result values refer to
-- the index of the last duplicate) and NaN values are ignored.
------------------------------------------------------------------------------------
function p.invert(arr)
	checkType("invert", 1, arr, "table")
	local isNan = p.isNan
	local map = {}
	for i, v in ipairs(arr) do
		if not isNan(v) then
			map[v] = i
		end
	end

	return map
end

------------------------------------------------------------------------------------
-- listToSet
--
-- Creates a set from the array part of the table. Indexing the set by any of the
-- values of the array returns true. For example, {"a", "b", "c"} ->
-- {a = true, b = true, c = true}. NaN values are ignored as Lua considers them
-- never equal to any value (including other NaNs or even themselves).
------------------------------------------------------------------------------------
function p.listToSet(arr)
	checkType("listToSet", 1, arr, "table")
	local isNan = p.isNan
	local set = {}
	for _, v in ipairs(arr) do
		if not isNan(v) then
			set[v] = true
		end
	end

	return set
end

------------------------------------------------------------------------------------
-- deepCopy
--
-- 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

------------------------------------------------------------------------------------
-- sparseConcat
--
-- 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 arr = {}

	local arr_i = 0
	for _, v in p.sparseIpairs(t) do
		arr_i = arr_i + 1
		arr[arr_i] = v
	end

	return table.concat(arr, sep, i, j)
end

------------------------------------------------------------------------------------
-- length
--
-- Finds the length of an array, or of a quasi-array with keys such as "data1",
-- "data2", etc., using an exponential search algorithm. 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, prefix)
	-- requiring module inline so that [[Module:Exponential search]] which is
	-- only needed by this one function doesn't get millions of transclusions
	local expSearch = require("Module:Exponential search")
	checkType('length', 1, t, 'table')
	checkType('length', 2, prefix, 'string', true)
	return expSearch(function (i)
		local key
		if prefix then
			key = prefix .. tostring(i)
		else
			key = i
		end
		return t[key] ~= nil
	end) or 0
end

------------------------------------------------------------------------------------
-- inArray
--
-- Returns true if valueToFind is a member of the array, and false otherwise.
------------------------------------------------------------------------------------
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
后中长是什么意思 21属什么 钢铁侠叫什么名字 jio是什么意思 吃什么药降尿酸快
doneed是什么牌子 阿司匹林有什么副作用 种草莓是什么意思 兴渠是什么菜 为什么晚上睡觉老是做梦
痛风不能吃什么食物 航母舰长是什么级别 鼻基底用什么填充最好 胎儿脐带绕颈是什么原因造成的 参谋是什么军衔
愚昧什么意思 多吃西红柿有什么好处 身体缺镁会有什么症状 金刚芭比什么意思 b3维生素又叫什么
小孩子发烧手脚冰凉是什么原因hcv9jop0ns6r.cn 三高不能吃什么食物hcv9jop6ns1r.cn 月经不调吃什么药好hcv8jop9ns6r.cn 阴虚内热吃什么中成药gangsutong.com 阴毛有什么用cj623037.com
红色加紫色是什么颜色hcv8jop4ns0r.cn 疴是什么意思hcv8jop3ns2r.cn 胃疼是什么感觉hcv9jop0ns9r.cn ep是什么意思hcv8jop7ns3r.cn 瘿瘤是什么意思hcv9jop0ns9r.cn
情人是什么意思jasonfriends.com 看见蛇过马路什么征兆xinjiangjialails.com 什么呀aiwuzhiyu.com 刚怀孕有什么办法打掉hcv9jop8ns1r.cn 吃什么皮肤会变白hcv9jop3ns6r.cn
急性腹泻拉水吃什么药hcv8jop4ns7r.cn 代沟是什么hcv8jop5ns5r.cn 面部神经痉挛吃什么药hcv8jop2ns9r.cn 什么叫基因检测hcv7jop6ns7r.cn 胃痛胃胀什么原因引起的hcv8jop5ns4r.cn
百度