zoukankan      html  css  js  c++  java
  • JS函数扩展

    // JScript 文件
    //===================================================

    //===================================================
    //扩展Array,增加IsInAyyay函数。函数功能:判断数组是否包含某元素

    Array.prototype.IsInAyyay=function(e)
    {
        for (var i=0;i<this.length;i++)
        {
            if (this[i]==e)
            {
                return true;
            }
         }
        return false;
    }
    Array.prototype.removeEmpty=function(e)
    {
        for (var i=0;i<this.length ;i++ )
        {
            if (this[i].length==0)
            {
                this.splice(i,1);
            }
        }
        return this;
    }
    String.prototype.CutLast=function(e)
    {
        if (this.substr(this.length-1)==e)
        {
            return this.substr(0,this.length-1);
        }
        else
        {//alert("return CutLast this"+"        "+this);
            return this;
        }
    }
    String.prototype.reMoveStr=function(e)
    {
        var reg;
        if (this.indexOf(e+",")==-1)
        {
            if (this.indexOf(e)!=-1)
            {
                reg = new RegExp(e);
                return this.replace(reg,"");
           
            }
            else
            {
                return this;
            }
        }
        else
        {
            reg = new RegExp(e+",");
            return this.replace(reg,"");

        }
    }
    String.prototype.padLeft=function(e,n)
    {
        var reValue="";
        if (this.length<n)
        {
            for (var i=0;i<n-1;i++)
            {
               
                reValue+=e;
            }
            return (reValue+this);
        }
        else
        {
            return this;
        }

    }

  • 相关阅读:
    【KM】BZOJ1937 [Shoi2004]Mst 最小生成树
    【动态规划+Floyd】OpenJudge3368
    【四边形不等式】HDU3506-Monkey Party
    【tarjan】BZOJ2140-稳定婚姻
    【并查集】BZOJ4668-冷战
    [ZJOI2010]贪吃的老鼠(网络流+建图)
    [NOI2010]航空管制(拓扑排序+贪心)
    [CERC2017]Intrinsic Interval(神仙+线段树)
    [CTSC2012]熟悉的文章(后缀自动机+动态规划)
    [CERC2014]Virus synthesis
  • 原文地址:https://www.cnblogs.com/tyb1222/p/1888809.html
Copyright © 2011-2022 走看看