锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲一区在线日韩在线深爱,成人在线免费视频,国内一区在线http://www.aygfsteel.com/jsdk999/category/16654.htmlzh-cnThu, 01 Mar 2007 15:35:35 GMTThu, 01 Mar 2007 15:35:35 GMT60鐢↗ava Script緙栧啓鐨勭被鎷烰AVA涓殑Maphttp://www.aygfsteel.com/jsdk999/articles/77723.htmlWindDCWindDCFri, 27 Oct 2006 12:06:00 GMThttp://www.aygfsteel.com/jsdk999/articles/77723.htmlhttp://www.aygfsteel.com/jsdk999/comments/77723.htmlhttp://www.aygfsteel.com/jsdk999/articles/77723.html#Feedback0http://www.aygfsteel.com/jsdk999/comments/commentRss/77723.htmlhttp://www.aygfsteel.com/jsdk999/services/trackbacks/77723.html/*
name:聽聽聽 Map.js
author:聽 WindDC
date:聽聽聽 2006-10-27
content: 鏈▼搴忕敤JS瀹炵幇綾繪嫙JAVA涓璏AP瀵瑰儚鐨勫姛鑳?br />*/

function Node(key,value){//閿煎瀵硅薄
聽聽聽 this.key=key;
聽聽聽 this.value=value;
}

function Map(){//Map綾?br />聽聽聽 this.nodes=new Array();
}

Map.prototype.put=function(key,value){//寰瀹瑰櫒涓姞鍏ヤ竴涓敭鍊煎
聽聽聽聽聽聽聽 for(var i=0;i<this.nodes.length;i++)
聽聽聽聽聽聽聽聽聽聽 if(this.nodes[i].key==key){//濡傛灉閿煎凡瀛樺湪錛屽垯put鏂規硶涓烘洿鏂板凡鏈夋暟鎹?br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽 this.nodes[i].value=value;
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 return;
聽聽聽聽聽聽聽聽聽聽 }
聽聽聽聽聽聽聽 var node=new Node(key,value);
聽聽聽聽聽聽聽 this.nodes.push(node);
聽聽聽聽聽聽聽 return;
}//put

聽聽
Map.prototype.get=function(key){//鑾峰彇鎸囧畾閿殑鍊?br />聽聽聽聽聽聽聽 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(){//鑾峰彇瀹瑰櫒涓璞$殑涓暟
聽聽聽 聽return this.nodes.length;
}//size

聽聽聽 聽聽聽聽
Map.prototype.clear=function(){//娓呯┖瀹瑰櫒
聽聽聽 聽while(this.nodes.length>0)
聽聽聽 聽聽聽 this.nodes.pop();聽聽聽聽聽
}//clear

Map.prototype.remove=function(key){//鍒犻櫎鎸囧畾鍊?br />聽聽聽 聽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//鍒犻櫎鐨勬槸絎竴涓厓绱?br />聽聽聽 聽聽聽聽聽聽 聽 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;
}



WindDC 2006-10-27 20:06 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 甘谷县| 尉氏县| 进贤县| 麦盖提县| 阳新县| 江津市| 宿松县| 台北县| 金湖县| 始兴县| 治多县| 黄梅县| 江口县| 大同市| 二连浩特市| 富蕴县| 墨江| 新和县| 新河县| 康保县| 盱眙县| 新昌县| 德惠市| 军事| 平顺县| 武功县| 都兰县| 福清市| 绿春县| 偃师市| 三都| 沂水县| 通化县| 扶沟县| 佛坪县| 蒙阴县| 盐津县| 江口县| 莎车县| 博野县| 闸北区|