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; | |