function Map () {
this.elements = new Array ();
Get the size of the map
This.size = function () {
return this.elements.length;
}
Determines whether the empty
This.isempty = function () {
Return (This.elements.length < 1);
}
Empty
This.clear = function () {
this.elements = new Array ();
}
Put in a Map object
This.put = function (_key, _value) {
This.elements.push ({
Key: _key,
Value: _value
});
}
Remove an object by key
This.remove = function (_key) {
var bln = false;
try {
for (i = 0; i < this.elements.length; i++) {
if (This.elements[i].key = = _key && typeof This.elements[i].key = = typeof _key) {
This.elements.splice (i, 1);
return true;
}
}
} catch (e) {
bln = false;
}
Return bln;
}
Gets an object based on the key
This.get = function (_key) {
try {
for (i = 0; i < this.elements.length; i++) {
if (This.elements[i].key = = _key && typeof This.elements[i].key = = typeof _key) {
return this.elements[i].value;
}
}
} catch (e) {
return null;
}
}
Returns an object of the specified index
This.element = function (_index) {
if (_index < 0 | | _index >= this.elements.length) {
return null;
}
return This.elements[_index];
}
Whether the key is included
This.containskey = function (_key) {
var bln = false;
try {
for (i = 0; i < this.elements.length; i++) {
if (This.elements[i].key = = _key && typeof This.elements[i].key = = typeof _key) {
bln = true;
}
}
} catch (e) {
bln = false;
}
Return bln;
}
Whether the value is included
This.containsvalue = function (_value) {
var bln = false;
try {
for (i = 0; i < this.elements.length; i++) {
if (This.elements[i].value = = _value && typeof this.elements[i].value = = typeof _value) {
bln = true;
}
}
} catch (e) {
bln = false;
}
Return bln;
}
Get all the values
This.values = function () {
var arr = new Array ();
for (i = 0; i < this.elements.length; i++) {
Arr.push (This.elements[i].value);
}
return arr;
}
Get all the keys
This.keys = function () {
var arr = new Array ();
for (i = 0; i < this.elements.length; i++) {
Arr.push (This.elements[i].key);
}
return arr;
}
}