We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8e33980 commit b097303Copy full SHA for b097303
src/_DataStructures_/HashTable/index.js
@@ -36,12 +36,14 @@ class HashTable {
36
for (let i = 0; i < loopTill; i += 1) {
37
const char = stringKey[i];
38
const value = char.charCodeAt(0) - 96;
39
- index = (index * PRIME_MULTIPLIER + value) % this.bucket.length;
+ // eslint-disable-next-line no-bitwise
40
+ index &= index;
41
+ index = index * PRIME_MULTIPLIER + value;
42
if (this.strongHash) {
- index = (index + PRIME_ADDER) % this.bucket.length;
43
+ index += PRIME_ADDER;
44
}
45
- return index;
46
+ return Math.abs(index % this.bucket.length);
47
48
49
_resize() {
0 commit comments