Map = function () {
this.objects = new Object();

// 加入元素
this.put = function (key, value) {
this.objects[key] = value;
};

// 删除元素
this.remove = function (key) {
this.objects[key] = undefined;
};

// 是否存在某键值
this.containsKey = function (key) {
return this.objects[key] ? true : false;
};

// 获取某元素
this.get = function(key) {
return this.objects[key];
};

// 是否存在某值
this.containsValue = function (value) {
for (var temp in this.objects) {
if (this.objects[temp] == value) {
return true;
}
}

return false;
};

// 集合大小
this.size = function () {
var counter = 0;
for (var temp in this.objects) {
counter ++;
}
return counter;
}
}

posted on 2017-09-05 14:43  喃博思睿  阅读(615)  评论(0编辑  收藏  举报