Skip to content

Commit 6249ad1

Browse files
committed
d
1 parent ef4f897 commit 6249ad1

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

src/js/data-structures/dictionary.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defaultToString } from '../util';
22
import { ValuePair } from './models/value-pair';
3-
3+
//字典实现
44
export default class Dictionary {
55
constructor(toStrFn = defaultToString) {
66
this.toStrFn = toStrFn;
@@ -78,4 +78,4 @@ export default class Dictionary {
7878
}
7979
return objString;
8080
}
81-
}
81+
}

src/js/data-structures/hash-table-linear-probing-lazy.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defaultToString } from '../util';
22
import { ValuePairLazy } from './models/value-pair-lazy';
3-
3+
//散列表冲突解决-线性探查(软删除方法)
44
export default class HashTableLinearProbingLazy {
55
constructor(toStrFn = defaultToString) {
66
this.toStrFn = toStrFn;
@@ -27,8 +27,8 @@ export default class HashTableLinearProbingLazy {
2727
if (key != null && value != null) {
2828
const position = this.hashCode(key);
2929
if (
30-
this.table[position] == null
31-
|| (this.table[position] != null && this.table[position].isDeleted)
30+
this.table[position] == null ||
31+
(this.table[position] != null && this.table[position].isDeleted)
3232
) {
3333
this.table[position] = new ValuePairLazy(key, value);
3434
} else {
@@ -51,18 +51,18 @@ export default class HashTableLinearProbingLazy {
5151
}
5252
let index = position + 1;
5353
while (
54-
this.table[index] != null
55-
&& (this.table[index].key !== key || this.table[index].isDeleted)
54+
this.table[index] != null &&
55+
(this.table[index].key !== key || this.table[index].isDeleted)
5656
) {
5757
if (this.table[index].key === key && this.table[index].isDeleted) {
5858
return undefined;
5959
}
6060
index++;
6161
}
6262
if (
63-
this.table[index] != null
64-
&& this.table[index].key === key
65-
&& !this.table[index].isDeleted
63+
this.table[index] != null &&
64+
this.table[index].key === key &&
65+
!this.table[index].isDeleted
6666
) {
6767
return this.table[position].value;
6868
}
@@ -79,15 +79,15 @@ export default class HashTableLinearProbingLazy {
7979
}
8080
let index = position + 1;
8181
while (
82-
this.table[index] != null
83-
&& (this.table[index].key !== key || this.table[index].isDeleted)
82+
this.table[index] != null &&
83+
(this.table[index].key !== key || this.table[index].isDeleted)
8484
) {
8585
index++;
8686
}
8787
if (
88-
this.table[index] != null
89-
&& this.table[index].key === key
90-
&& !this.table[index].isDeleted
88+
this.table[index] != null &&
89+
this.table[index].key === key &&
90+
!this.table[index].isDeleted
9191
) {
9292
this.table[index].isDeleted = true;
9393
return true;
@@ -129,4 +129,4 @@ export default class HashTableLinearProbingLazy {
129129
}
130130
return objString;
131131
}
132-
}
132+
}

src/js/data-structures/hash-table-linear-probing.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defaultToString } from '../util';
22
import { ValuePair } from './models/value-pair';
33

4+
//散列表冲突解决-线性探查(移动方法)
45
export default class HashTableLinearProbing {
56
constructor(toStrFn = defaultToString) {
67
this.toStrFn = toStrFn;
@@ -121,4 +122,4 @@ export default class HashTableLinearProbing {
121122
}
122123
return objString;
123124
}
124-
}
125+
}

src/js/data-structures/hash-table-separate-chaining.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { defaultToString } from '../util';
22
import LinkedList from './linked-list';
33
import { ValuePair } from './models/value-pair';
4-
4+
//散列表冲突解决-分离链接
55
export default class HashTableSeparateChaining {
66
constructor(toStrFn = defaultToString) {
77
this.toStrFn = toStrFn;
@@ -103,4 +103,4 @@ export default class HashTableSeparateChaining {
103103
}
104104
return objString;
105105
}
106-
}
106+
}

src/js/data-structures/hash-table.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defaultToString } from '../util';
22
import { ValuePair } from './models/value-pair';
3-
3+
//散列表
44
export default class HashTable {
55
constructor(toStrFn = defaultToString) {
66
this.toStrFn = toStrFn;
@@ -82,4 +82,4 @@ export default class HashTable {
8282
}
8383
return objString;
8484
}
85-
}
85+
}

0 commit comments

Comments
 (0)