Skip to content

Instantly share code, notes, and snippets.

@OneCent01
Created June 11, 2017 22:32
Show Gist options
  • Save OneCent01/37e9b710a73691268916e12b3697bf47 to your computer and use it in GitHub Desktop.
Save OneCent01/37e9b710a73691268916e12b3697bf47 to your computer and use it in GitHub Desktop.
retrieve method for hash table value retrieval in Javascript
HashTable.prototype.retrieve = function(key) {
var index = key.hashCode();
var bucket = this._storage.get(index);
for (var i = 0; i < bucket.length; i++) {
if (bucket[i][0] === key) {
return bucket[i][1];
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment