3 basic methods:
1-method put(key, value);
2-method remove(key);
3-method get(key);
here is basic code:
function HashTable() {
let table = [];
let looselooseHash = function (key) {
let hash = 0;
for (let i = 0; i < key.length; i++) {
hash += key.charCodeAt(i);
}
return hash % 37;
};
this.put = function (key, value) {
let position = looselooseHash(key);
console.log(position + " - " + key);
table[position] = value;
};
}
let table = new HashTable();
table.put("nurbekjon", "nur.softwaredev");
table.put("nurbekjo", "nurbek.malikov@gmail.com");
table.put("azamat", "azam@gmail.com");
Top comments (0)