什么样的白带是怀孕了| mas是什么意思| 端午节是什么星座| 什么书在书店买不到| 田螺姑娘是什么意思| 早上起床头晕是什么原因| 谷维素治什么病| 广西属于什么方向| 金鱼吃什么| 大人吃什么排黄疸快| 男性下焦湿热吃什么药| 焦虑症是什么意思| 5月是什么星座| 自我救赎是什么意思| 江浙沪是什么意思| 毒是什么意思| 山药长什么样| 大禹的爸爸叫什么| 腋下异味挂什么科| 三十七岁属什么生肖| 世界上最贵的狗是什么| 7月20号是什么星座| 荔枝什么人不能吃| 一什么永什么成语| 对蚊子过敏是什么症状| 冬天吃什么| 什么是m| 梨状肌综合征挂什么科| 女人人中深代表什么| 解酒吃什么| 吐信子是什么意思啊| 什么是筋膜炎| 手指为什么会脱皮| 双重否定句是什么意思| anca医学上是什么意思| 脂肪燃烧是什么感觉| 邮编什么意思| 吃鸡蛋补什么| 钛对人体有什么好处| 睡觉梦到蛇是什么意思| 肺与什么相表里| 关塔那摩监狱为什么在古巴| 榴莲吃多了有什么危害| 颈部ct能检查出什么| 孕晚期吃什么长胎不长肉| 什么人从来不看医生| 经常出汗是什么原因| 早上起来后背疼是什么原因| 天鹅吃什么| 毛肚是什么东西| 喝什么解酒最快最有效| 安宫丸什么时候吃效果是最佳的| 飞蚊症是什么原因引起的| 阴囊积液是什么原因引起的| 草是什么颜色的| 为什么不建议割鼻息肉| 牙龈发炎用什么药| 香菜什么时候种| 腰果不能和什么一起吃| 结肠炎吃什么药治疗效果好| epo是什么意思| 61是什么意思| 慢性肠炎用什么药| ppl什么意思| 一级医院是什么医院| 减肥早餐适合吃什么| pacu是什么意思| 排便方式改变指什么| 阿飘是什么意思| 扇子骨是什么肉| 雪霁是什么意思| 01年属什么的| 尿酸高吃什么| 春秋大梦是什么意思| 息肉样病变是什么意思| 老人出汗多是什么原因| 什么叫肺间质病变| 闲云野鹤指什么生肖| 肾气不固吃什么中成药| 血吸虫是什么动物| 家里进蝙蝠什么预兆| 什么时间吃水果比较好| 疖肿是什么样子的图片| 梦到认识的人死了是什么意思| 吃什么补气补血最见效| 医院量身高为什么会矮| 耳朵里面痒是什么原因| 发物是什么| 1月15日什么星座| 黑裤子配什么颜色的鞋| 指甲不平有凹凸是什么原因| 豆腐吃多了有什么坏处| 区教育局局长是什么级别| 生二胎应该注意什么| 葵瓜子吃多了有什么危害| 芝柏手表什么档次| 脾胃虚寒吃什么食物好| 甲亢什么症状表现| 奶奶的姐姐叫什么| 体制内是什么意思| 尿蛋白高是什么病| 为什么眼睛老是痒| 柴米油盐什么意思| 噫气是什么意思| 什么是头寸| 生辰八字指什么| 梦见很多猪是什么意思| 梦见腿断了是什么意思| 额头凉凉的是什么原因| 腿抽筋是什么原因造成的| 胜造七级浮屠是什么意思| 巫师是什么意思| 单丛属于什么茶| 头晕恶心想吐吃什么药| rna是什么意思| 结婚35周年是什么婚| 桑葚搭配什么泡水喝最好| 左胸下面是什么部位| ol什么意思| 水肿是什么症状| 邪气是什么意思| 功什么不什么| 火加良念什么| 节育环是什么| 什么水适合婴儿冲奶粉| 酉什么意思| classy是什么意思| 西汉与东汉有什么区别| 蛰伏是什么意思| 欺人太甚什么意思| 豆浆和什么不能一起吃| 吃二甲双胍为什么会瘦| 阴性什么意思| 60岁是什么之年| 芳心是什么意思| 护理学什么| 沉迷是什么意思| 美是什么生肖| 壁立千仞无欲则刚是什么意思| 云是什么意思| 芸豆是什么豆| 白果治什么病| 桂鱼是什么鱼| 大运流年是什么意思| 脚气长什么样| 业火是什么意思| 瓜子脸适合什么刘海| 学习机什么牌子好| 易出汗是什么原因| 什么钙片补钙效果最好| 下身有异味用什么药| 户籍地址填什么| 腐女什么意思| 混不吝是什么意思| prich是什么牌子| 屈髋是什么姿势| 什么是高原反应| 中午吃什么饭| 眼屎多吃什么药效果好| 馐什么意思| 嘉庆叫什么名字| 肩胛骨疼是什么原因| 军衔是什么意思| 刘备和刘邦是什么关系| 补办结婚证需要什么手续| 二灰是什么| 为什么会肛裂| 一吃东西就牙疼是什么原因引起的| 射手座的幸运色是什么颜色| 尿道痒男吃什么消炎药| 黄原胶是什么| 显著是什么意思| 一什么对联| 得艾滋病的人有什么症状| 胃糜烂吃什么药效果好| 左眼皮一直跳是什么原因| 痣为什么会越来越多| 罗汉果泡水有什么好处| 闲鱼卖出的东西钱什么时候到账| 珍珠鸟吃什么| 辛辣都包括什么| 许冠杰属什么生肖| 痔疮不治会有什么危害| 子宫内膜厚什么原因引起的| 呼吸道感染一般用什么消炎药| 1a是什么意思| 人为什么会长痔疮| 2004年是什么生肖| 地球什么时候毁灭| 查贫血挂什么科| 吃完头孢不能吃什么| 高反人群一般是什么人| 乳头变大是什么原因| mg是什么意思| 砷对人体有什么危害| 堃字的寓意是什么意思| 中秋节送什么好| 什么时候满月| 慢性肠炎吃什么药调理| 剪刀石头布什么意思| 子宫复旧不良有什么症状| 澳门为什么叫澳门| 亚甲减是什么意思| 骨头坏死是什么感觉| sy是什么意思| 牛仔裤搭配什么衣服好看| 被蚂蚁咬了用什么药| 出虚恭是什么意思| 肺气泡是什么病| 褒义是什么意思| 前胸疼是什么原因| 磨蹭是什么意思| 生物工程专业学什么| 舌头紫红色是什么原因| 湿疹有什么症状和图| 血糖高有什么症状| 益母草颗粒什么时候喝| 环状肉芽肿是什么皮肤病| 梦见皮带断了什么预兆| 知了幼虫叫什么| 人为什么会打呼噜| pearl什么意思| 女性私处长痘痘是什么原因| 三尖瓣轻度反流是什么意思| 中校相当于政府什么官| 酸梅汤不能和什么一起吃| 掉头发吃什么好| 新加坡什么工作最挣钱| 赖氨酸是什么| 牛肉馅配什么菜包饺子好吃| 杭州都有什么区| 喝酒前吃什么药| 偏安一隅是什么意思| 免签国家是什么意思| 中午1点是什么时辰| 五十路是什么意思| 治疗白头发挂什么科| 12月25日是什么日子| 水晶消磁是什么意思| 心衰做什么检查能确诊| 嗓子咽口水疼吃什么药| 红糖是什么做的| 杀阴虱用什么药最好| 哺乳期吃什么奶水多| 属狗的幸运色是什么颜色| 什么的教导| 怀孕10多天有什么症状| 孙策字什么| 放屁是什么意思| bdsm什么意思| 慢性浅表性胃炎吃什么药好| 手术后发烧是什么原因| 幼儿急疹吃什么药| 猿人头是什么牌子| 心悸是什么感觉| 指甲竖纹是什么原因| 头发汗多是什么原因| 1934年属什么| 层出不穷是什么意思| 什么是继发性肺结核| 日斤念什么字| 急性肠胃炎是什么引起的| 难怪是什么意思| 发烧反反复复是什么原因| 百度Jump to content

用车|政策空白期 新能源客车正经历首次阵痛期

?????????? ???
百度 “除夕、初一、初五,十五,都是这样度过的,有时要凌晨两三点钟才能回家休息。

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)
	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 tostring(v) == '-nan'
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.
		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, 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

--[[
-- 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
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
禅心是什么意思 m蛋白是什么 什么是工作日 1946年属什么生肖 什么肉不含嘌呤
篦子是什么东西 胃下垂吃什么药最好 感冒喝什么水好得快 做梦梦见蛇是什么征兆 开天辟地是什么生肖
来月经为什么会肚子痛 什么人不适合吃榴莲 煮中药用什么锅 出汗多吃什么好 尿道感染是什么原因引起的
上火吃什么食物 解体是什么意思 报告是什么意思 20岁长白头发是什么原因造成的 墨西哥讲什么语言
1972年是什么年hcv9jop0ns1r.cn 尿急尿频吃什么药hcv8jop2ns9r.cn 白带发黄是什么妇科病hcv7jop6ns6r.cn 茶色尿液提示什么病hcv9jop5ns9r.cn 脑ct挂什么科hcv8jop8ns6r.cn
爱长闭口用什么护肤品hcv9jop6ns6r.cn 三个王念什么hcv8jop0ns1r.cn 李子什么人不能吃0297y7.com 碧字五行属什么hcv9jop3ns9r.cn 瘴气是什么hcv8jop7ns4r.cn
白热化阶段是什么意思zhiyanzhang.com 股票举牌什么意思hcv9jop6ns7r.cn 小钢炮是什么意思hcv9jop2ns1r.cn 太阳筋疼是什么原因hcv9jop1ns9r.cn 长征是什么意思hcv9jop2ns1r.cn
首选是什么意思imcecn.com 鸡米头是什么hcv7jop9ns9r.cn 天秤男和什么星座最配hcv8jop5ns6r.cn 龟头瘙痒用什么药膏hcv8jop5ns8r.cn 石楠花是什么味道hcv7jop6ns7r.cn
百度