<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    /*
    name:??? Map.js
    author:? WindDC
    date:??? 2006-10-27
    content: 本程序用JS實(shí)現(xiàn)類擬JAVA中MAP對(duì)像的功能
    */

    function Node(key,value){//鍵值對(duì)對(duì)象
    ??? this.key=key;
    ??? this.value=value;
    }

    function Map(){//Map類
    ??? this.nodes=new Array();
    }

    Map.prototype.put=function(key,value){//往容器中加入一個(gè)鍵值對(duì)
    ??????? for(var i=0;i<this.nodes.length;i++)
    ?????????? if(this.nodes[i].key==key){//如果鍵值已存在,則put方法為更新已有數(shù)據(jù)
    ?????????????? this.nodes[i].value=value;
    ?????????????? return;
    ?????????? }
    ??????? var node=new Node(key,value);
    ??????? this.nodes.push(node);
    ??????? return;
    }//put

    ??
    Map.prototype.get=function(key){//獲取指定鍵的值
    ??????? for(var i=0;i<this.nodes.length;i++)
    ?????????? if(this.nodes[i].key==key)
    ????????????? return this.nodes[i].value;
    ??????? return null;
    }//get
    ????
    Map.prototype.size=function(){//獲取容器中對(duì)象的個(gè)數(shù)
    ??? ?return this.nodes.length;
    }//size

    ??? ????
    Map.prototype.clear=function(){//清空容器
    ??? ?while(this.nodes.length>0)
    ??? ??? this.nodes.pop();?????
    }//clear
    ?
    Map.prototype.remove=function(key){//刪除指定值
    ??? ?for(var i=0;i<this.nodes.length;i++)
    ??? ??? if(this.nodes[i].key==key){
    ??? ??? ?? if(i>0)
    ??? ????????? var nodes1=this.nodes.concat(this.nodes.slice(0,i-1),this.nodes.slice(i+1));
    ??? ?????? else//刪除的是第一個(gè)元素
    ??? ?????? ? var nodes1=nodes.slice(1);
    ??? ?????? this.nodes=nodes1;

    ??? ??? }
    }//remove

    ???
    Map.prototype.isEmpty=function(){//是否為空
    ??? ?if(this.nodes.length==0)
    ??? ?? return true;
    ??? ?else
    ??? ?? return false;
    }//isEmpty
    ???
    Map.prototype.toString=function(){
    ???? var str="[";
    ???? for(var i=0;i<this.nodes.length;i++){
    ??????? if(i<this.nodes.length-1)
    ?????????? str=str+this.nodes[i].key+",";
    ?????? else
    ?????????? str=str+this.nodes[i].key;????
    ?? ?}
    ??? str=str+"]";
    ????return str;
    }

    posted on 2006-10-27 20:06 WindDC 閱讀(323) 評(píng)論(0)  編輯  收藏 所屬分類: JS腳本

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
     
    主站蜘蛛池模板: 亚洲视频在线不卡| 亚洲精品国产福利一二区| 久久综合亚洲鲁鲁五月天| 香蕉免费一区二区三区| 久久精品国产亚洲AV麻豆不卡| 香蕉免费在线视频| 亚洲AV无码久久精品成人| 永久在线观看免费视频 | 亚洲福利精品电影在线观看| 九九精品国产亚洲AV日韩| 国产成人无码a区在线观看视频免费 | 久久免费区一区二区三波多野| 亚洲AV无码成人网站久久精品大 | 特级毛片免费播放| 美腿丝袜亚洲综合| 久久青草91免费观看| 亚洲日本精品一区二区| 免费能直接在线观看黄的视频| 亚洲人成综合网站7777香蕉| 免费看大黄高清网站视频在线| 另类图片亚洲校园小说区| 亚洲色婷婷综合久久| 1000部拍拍拍18勿入免费视频下载| 亚洲国产精品xo在线观看| 在线播放高清国语自产拍免费| 美女被免费视频网站a| 亚洲大尺度无码专区尤物| 免费观看美女用震蛋喷水的视频| 欧洲 亚洲 国产图片综合| 亚洲日韩精品无码专区网站 | 丰满少妇作爱视频免费观看| 亚洲av无码一区二区三区不卡| 99爱免费观看视频在线| 久久精品国产亚洲AV蜜臀色欲| 免费人成在线观看网站视频| a级毛片在线免费| 亚洲乱码中文字幕小综合| 成年丰满熟妇午夜免费视频| 香蕉国产在线观看免费| 亚洲网址在线观看| 可以免费观看的一级毛片|