复制代码代码如下:
var map = function () {
this._entrys = new Array ();
this.put = function (clave, valor) {
if (key == null || key == Undefined) {
devolver;
}
índice var = this._getIndex (clave);
if (index == -1) {
VAR entry = new Object ();
Entry.Key = Key;
entry.Value = Value;
this._entrys [this._entrys.length] = entry;
}demás{
this._entrys [índice] .value = valor;
}
};
this.get = function (key) {
índice var = this._getIndex (clave);
return (índice! = -1)? this._entrys [índice] .value: null;
};
this.remove = function (key) {
índice var = this._getIndex (clave);
if (index! = -1) {
this._entrys.splice (índice, 1);
}
};
this.clear = function () {
this._entrys.length = 0 ;;
};
this.contains = function (key) {
índice var = this._getIndex (clave);
return (índice! = -1)? verdadero: falso;
};
this.getCount = function () {
devolver esto._entrys.length;
};
this.getEntrys = function () {
devolver esto._Entrys;
};
this._getIndex = function (key) {
if (key == null || key == Undefined) {
regreso -1;
}
var _length = this._entrys.length;
para (var i = 0; i <_length; i ++) {
entry var = this._entrys [i];
if (entry == null || entry == Undefined) {
continuar;
}
if (entry.key === key) {// igual
regresar i;
}
}
regreso -1;
};
this._ToString = function () {
var string = "";
para (var i = 0; i <this.getEntrys (). Longitud; i ++) {
String+= this.getEntrys () [i] .key+"::"+this.getEntrys () [i] .value;
if (i! = this.getEntrys (). longitud-1) {
String += ";";
}
}
cadena de retorno;
};
};