function HashTable() {
this.storage = []
this.count = 0
this.limit = 7
HashTable.prototype.hashFunc = function(str, size) {
var hashCode = 0
for(var i = 0; i < str.length; i++){
hashCode = 37 * hashCode + str.charCodeAt(i)
}
var index = hashCode % size
return index
}
HashTable.prototype.put = function(key, value) {
var index = this.hashFunc(key, this.limit)
var bucket = this.storage[index]
if (bucket == null) {
bucket = []
this.storage[index] = bucket
}
for (var i=0; i<bucket.length;i++) {
var tuple = bucket[i]
if (tuple[0] == key) {
tuple[1] = value
return
}
}
bucket.push([key, value])
this.count++
if (this.count > this.limit * 0.7