Created
June 11, 2017 22:32
-
-
Save OneCent01/37e9b710a73691268916e12b3697bf47 to your computer and use it in GitHub Desktop.
retrieve method for hash table value retrieval in Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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