--[[
 -- @Description:
 -- Hello , DiaoSi ~ ( or not ? ) ,glad you saw my comment
 -- If you think my mod is okay , you can sponsor my breakfast by a tiny amount donation  ($_$)
 -- paypal:td1madao@163.com     alipay:td1madao@163.com
 -- If any question ,Please email me
 -- What's more ,don't modify and republish my mods . 3Q for cooperation
 -- What's more ,don't modify and republish my mods . 3Q for cooperation
 -- What's more ,don't modify and republish my mods . 3Q for cooperation
 -- @version 1.0.0
 -- @author td1madao
 -- @email td1madao@163.com
 -- @qq 360810498
 -- @date 16/8/6
 ]]
if not table.td1madao_clone then
    table.td1madao_clone = function(arr)
        local tab = {}
        for k, v in pairs(arr or {}) do
            if type(v) ~= "table" then
                tab[k] = v
            else
                tab[k] = table.td1madao_clone(v)
            end
        end
        return tab
    end
end

if not table.td1madao_entLen then
    table.td1madao_entLen = function(tab)
        local count = 0
        for _ in pairs(tab or {}) do
            count = count + 1
        end
        return count
    end
end

if not table.td1madao_entExist then
    table.td1madao_entExist = function(tab)
        for _ in pairs(tab or {}) do
            return true
        end
        return false
    end
end

if not table.td1madao_entShallowEqual then
    table.td1madao_entShallowEqual = function(tab1, tab2)
        for k, v1 in pairs(tab1 or {}) do
            if not v1 == tab2[k] then
                return false
            end
        end
        return true
    end
end


if not table.td1madao_size then
    table.td1madao_size = function(arr)
        local size = 0
        if arr ~= nil then
            for k, v in pairs(arr) do
                if k and k > size then
                    size = k
                end
            end
        end
        if #arr > size then
            size = #arr
        end
        return size
    end
end
if not table.td1madao_pop then
    table.td1madao_pop = function(arr)
        if not arr then
            return false
        end
        return table.remove(arr, #arr)
    end
end
if not string.td1madao_replaceAll then
    string.td1madao_replaceAll = function(inputstr, from, to)
        if not inputstr or not from or not to then
            return inputstr
        end
        return string.gsub(inputstr, from, to)
    end
end
if not string.td1madao_split then
    string.td1madao_split = function(inputstr, sep)
        if not string.td1madao_contain(inputstr, sep) then
            return { inputstr }
        end
        if string.td1madao_startWith(inputstr, sep) then
            return { "", string.sub(inputstr, 2, string.len(inputstr)) }
        end
        if sep == nil then
            sep = "%s"
        end
        local t = {};
        local i = 1
        for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
            t[i] = str
            i = i + 1
        end
        return t
    end
end
if not string.td1madao_contain then
    string.td1madao_contain = function(str, mark)
        if not str or not mark then
            return false
        end
        return string.find(str, mark)
    end
end
if not string.td1madao_startWith then
    string.td1madao_startWith = function(inputstr, sep)
        if not inputstr or not sep then
            return false
        end
        return string.sub(inputstr, 1, 1) == sep
    end
end