function Map() {
this.keys = new Array();
this.data = new Array();
//添加鍵值對
this.set = function (key, value) {
if (this.data[key] == null) {//如鍵不存在則身【鍵】數組添加鍵名
this.keys.push(value);
}
this.data[key] = value;//給鍵賦值
};
//獲取鍵對應的值
this.get = function (key) {
return this.data[key];
};
//去除鍵值,(去除鍵數據中的鍵名及對應的值)
this.remove = function (key) {
this.keys.remove(key);
this.data[key] = null;
};
//判斷鍵值元素是否為空
this.isEmpty = function () {
return this.keys.length == 0;
};
//獲取鍵值元素大小
this.size = function () {
return this.keys.length;
};
}