//判断MAP中是否含有指定KEY的元素 this.containsKey = function(_key) { var bln = false; try { for (i = 0; i < this.elements.length; i++) { if (this.elements[i].key == _key) { bln = true; } } } catch (e) { bln = false; } return bln; };
//判断MAP中是否含有指定VALUE的元素 this.containsValue = function(_value) { var bln = false; try { for (i = 0; i < this.elements.length; i++) { if (this.elements[i].value == _value) { bln = true; } } } catch (e) { bln = false; } return bln; };
//判断MAP中是否含有指定VALUE的元素 this.containsObj = function(_key,_value) { var bln = false; try { for (i = 0; i < this.elements.length; i++) { if (this.elements[i].value == _value && this.elements[i].key == _key) { bln = true; } } } catch (e) { bln = false; } return bln; };
//获取MAP中所有VALUE的数组(ARRAY) this.values = function() { var arr = new Array(); for (i = 0; i < this.elements.length; i++) { arr.push(this.elements[i].value); } return arr; };
//获取MAP中所有VALUE的数组(ARRAY) this.valuesByKey = function(_key) { var arr = new Array(); for (i = 0; i < this.elements.length; i++) { if (this.elements[i].key == _key) { arr.push(this.elements[i].value); } } return arr; };
//获取MAP中所有KEY的数组(ARRAY) this.keys = function() { var arr = new Array(); for (i = 0; i < this.elements.length; i++) { arr.push(this.elements[i].key); } return arr; };
//获取key通过value this.keysByValue = function(_value) { var arr = new Array(); for (i = 0; i < this.elements.length; i++) { if(_value == this.elements[i].value){ arr.push(this.elements[i].key); } } return arr; };
//获取MAP中所有KEY的数组(ARRAY) this.keysRemoveDuplicate = function() { var arr = new Array(); for (i = 0; i < this.elements.length; i++) { var flag = true; for(var j=0;j<arr.length;j++){ if(arr[j] == this.elements[i].key){ flag = false; break; } } if(flag){ arr.push(this.elements[i].key); } } return arr; }; }