mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-09-20 07:43:04 +08:00
Merge 085bb2973e
into ca3d16dcce
This commit is contained in:
commit
4a1c8e51d4
@ -12,7 +12,7 @@ export default class HashTable {
|
||||
*/
|
||||
constructor(hashTableSize = defaultHashTableSize) {
|
||||
// Create hash table of certain size and fill each bucket with empty linked list.
|
||||
this.buckets = Array(hashTableSize).fill(null).map(() => new LinkedList());
|
||||
this.buckets = new Array(hashTableSize).fill(null).map(() => new LinkedList());
|
||||
|
||||
// Just to keep track of all actual keys in a fast way.
|
||||
this.keys = {};
|
||||
|
@ -101,7 +101,7 @@ export default class LinkedList {
|
||||
|
||||
// If the head must be deleted then make next node that is different
|
||||
// from the head to be a new head.
|
||||
while (this.head && this.compare.equal(this.head.value, value)) {
|
||||
if (this.head && this.compare.equal(this.head.value, value)) {
|
||||
deletedNode = this.head;
|
||||
this.head = this.head.next;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user