function mapPut(codeType){
var hashMap = new Map();
var url = "code/findCodeByCodeType";
var jsonStr = "codeTypeName="+codeType;
var obj = jsonSubmit(url,formToJson(jsonStr));
$(obj).each(function(index) {
var val = obj[index];
hashMap.put(val.code,val.name);
hashMap.parent(codeType);
});
return hashMap;
}
function Map() {
this.objects = new Object();
// 加入元素
this.put = function (key, value) {
this.objects[key] = value;
};
this.parent=function(parentName){ this.name = parentName;};
this.name;
// 删除元素
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;
}
}
js map用法实例
最新推荐文章于 2024-08-07 14:56:05 发布