mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-10 11:09:43 +08:00
Merge 5df28bd5b5
into ca3d16dcce
This commit is contained in:
commit
a6d951c874
@ -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