复制代码代码如下:
خريطة var = function () {
this._entrys = new array () ؛
this.put = الدالة (المفتاح ، القيمة) {
if (key == null || key == undefined) {
يعود؛
}
var index = this._getIndex (key) ؛
if (index == -1) {
var entry = new Object () ؛
enter.Key = Key ؛
enter.value = value ؛
this._entrys [this._entrys.length] = intrad ؛
}آخر{
this._entrys [index] .value = value ؛
}
} ؛
this.get = function (key) {
var index = this._getIndex (key) ؛
العودة (فهرس! = -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) ؛
العودة (فهرس! = -1)؟ صحيح: خطأ
} ؛
this.getCount = function () {
إرجاع this._entrys.length ؛
} ؛
this.getentrys = function () {
إرجاع this._entrys ؛
} ؛
this._getIndex = function (مفتاح) {
if (key == null || key == undefined) {
العودة -1 ؛
}
var _length = this._entrys.length ؛
لـ (var i = 0 ؛ i <_length ؛ i ++) {
var entry = this._entrys [i] ؛
if (intern == null || intern == undefined) {
يكمل؛
}
if (under.key === KEY) {// equary
العودة أنا.
}
}
العودة -1 ؛
} ؛
this._tostring = function () {
var string = "" ؛
لـ (var i = 0 ؛ i <this.getentrys (). length ؛ i ++) {
string+= this.getentrys () [i] .Key+"::"+this.getentrys () [i] .value ؛
if (i! = this.getentrys (). length-1) {
سلسلة += "؛" ؛
}
}
سلسلة العودة
} ؛
} ؛