复制代码代码如下:
var map = function(){
this._entrys = new array();
this.put = function(key、value){
if(key == null || key == undefined){
戻る;
}
var index = this._getIndex(key);
if(index == -1){
var entry = new object();
entry.key = key;
entry.value = value;
this._entrys [this._entrys.length] = entry;
}それ以外{
this._entrys [index] .value = value;
}
};
this.get = function(key){
var index = this._getIndex(key);
return(index!= -1)? this._entrys [index] .value:null;
};
this.remove = function(key){
var index = this._getIndex(key);
if(index!= -1){
this._entrys.splice(index、1);
}
};
this.clear = function(){
this._entrys.length = 0 ;;
};
this.contains = function(key){
var index = this._getIndex(key);
return(index!= -1)? True:false;
};
this.getCount = function(){
this._entrys.length;
};
this.getEntrys = function(){
this._entrysを返します。
};
this._getIndex = function(key){
if(key == null || key == undefined){
return -1;
}
var _length = this._entrys.length;
for(var i = 0; i <_length; i ++){
var entry = this._entrys [i];
if(entry == null || entry == undefined){
続く;
}
if(entry.key === key){//等しい
私を返します。
}
}
return -1;
};
this._toString = function(){
var string = "";
for(var i = 0; i <this.getEntrys()。length; i ++){
string+= this.getEntrys()[i] .key+"::"+this.getEntrys()[i] .value;
if(i!= this.getEntrys()。長さ1){
string += ";";
}
}
文字列を返します。
};
};