File size: 672 Bytes
bc20498 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
var UniqueIDGeneretor = require('./UniqueIDGeneretor');
function HashMap() {
this.map = {};
this.keys = [];
}
HashMap.prototype.put = function (key, value) {
var theId = UniqueIDGeneretor.createID(key);
if (!this.contains(theId)) {
this.map[theId] = value;
this.keys.push(key);
}
};
HashMap.prototype.contains = function (key) {
var theId = UniqueIDGeneretor.createID(key);
return this.map[key] != null;
};
HashMap.prototype.get = function (key) {
var theId = UniqueIDGeneretor.createID(key);
return this.map[theId];
};
HashMap.prototype.keySet = function () {
return this.keys;
};
module.exports = HashMap;
|