复制代码代码如下::
var map = function () {
this._entrys = new Array ();
this.put = Funktion (Schlüssel, Wert) {
if (key == null || key == undefiniert) {
zurückkehren;
}
var index = this._getIndex (Schlüssel);
if (index == -1) {
var Eintrag = neues Objekt ();
Eintrag.Key = Key;
Eintrag.Value = Wert;
this._entrys [this.entrys.length] = Eintrag;
}anders{
this.trys [index] .Value = value;
}
};
this.get = function (Schlüssel) {
var index = this._getIndex (Schlüssel);
return (index! = -1)? this.trys [Index] .Value: null;
};
this.remove = function (Schlüssel) {
var index = this._getIndex (Schlüssel);
if (index! = -1) {
this._entrys.spleplice (Index, 1);
}
};
this.clear = function () {
this._entrys.length = 0 ;;
};
this.contains = function (Schlüssel) {
var index = this._getIndex (Schlüssel);
return (index! = -1)? wahr: falsch;
};
this.getCount = function () {
zurückgeben._entrys.length;
};
this.getEntrys = function () {
Gibt dies zurück.
};
this._getindex = function (Schlüssel) {
if (key == null || key == undefiniert) {
Return -1;
}
var _length = this.terys.length;
für (var i = 0; i <_length; i ++) {
var Eintrag = this._entrys [i];
if (Eintrag == NULL || Eintrag == undefiniert) {
weitermachen;
}
if (Eintrag.Key === Key) {// gleich
kehre I zurück;
}
}
Return -1;
};
this._toString = function () {
var string = "";
für (var i = 0; i <this.getEntrys (). Länge; i ++) {
String+= this.getEnrys () [i] .Key+"::"+this.getEnrys () [i] .Value;
if (i! = this.getEntrys (). Länge-1) {
String += ";";
}
}
Return String;
};
};