Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3cc813d

Browse files
committed
update: used fill() to fill array with null
1 parent ea7853e commit 3cc813d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

‎src/_DataStructures_/HashTable/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ class HashTable {
1111
this.threshold = 0.7;
1212
// the main bucket
1313
this.bucket = new Array(this.slot);
14+
// fill the bucket with null
15+
// for (let i = 0; i < this.slot; i += 1) this.bucket[i] = null;
16+
this.bucket.fill(null);
1417
this.allowResize = allowResize;
1518
this.strongHash = strongHash;
1619
if (custonHash) {
1720
// eslint-disable-next-line no-underscore-dangle
1821
this._hash = custonHash;
1922
}
20-
21-
// fill the bucket with null
22-
for (let i = 0; i < this.slot; i += 1) this.bucket[i] = null;
2323
}
2424

2525
_hash(key) {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /