mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Compare commits
2 Commits
a6d951c874
...
7a1b0020e0
Author | SHA1 | Date | |
---|---|---|---|
|
7a1b0020e0 | ||
|
5df28bd5b5 |
@ -85,7 +85,11 @@ export default class HashTable {
|
|||||||
* @return {*}
|
* @return {*}
|
||||||
*/
|
*/
|
||||||
get(key) {
|
get(key) {
|
||||||
const bucketLinkedList = this.buckets[this.hash(key)];
|
const computedHash = this.keys[key]?? null;
|
||||||
|
if(computedHash === null){
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const bucketLinkedList = this.buckets[computedHash];
|
||||||
const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key });
|
const node = bucketLinkedList.find({ callback: (nodeValue) => nodeValue.key === key });
|
||||||
|
|
||||||
return node ? node.value.value : undefined;
|
return node ? node.value.value : undefined;
|
||||||
|
Loading…
Reference in New Issue
Block a user