Several bug fixes.
This commit is contained in:
parent
53d91db10d
commit
8effa58a59
@ -47,7 +47,6 @@ class MaxHeap {
|
|||||||
while (true) {
|
while (true) {
|
||||||
// 判断节点 i, l, r 中值最大的节点,记为 ma
|
// 判断节点 i, l, r 中值最大的节点,记为 ma
|
||||||
int l = left(i), r = right(i), ma = i;
|
int l = left(i), r = right(i), ma = i;
|
||||||
// 若节点 i 最大或索引 l, r 越界,则无须继续堆化,跳出
|
|
||||||
if (l < size() && maxHeap[l] > maxHeap[ma])
|
if (l < size() && maxHeap[l] > maxHeap[ma])
|
||||||
ma = l;
|
ma = l;
|
||||||
if (r < size() && maxHeap[r] > maxHeap[ma])
|
if (r < size() && maxHeap[r] > maxHeap[ma])
|
||||||
|
|||||||
@ -83,7 +83,6 @@ class ArrayHashMap {
|
|||||||
print() {
|
print() {
|
||||||
let pairSet = this.entries();
|
let pairSet = this.entries();
|
||||||
for (const pair of pairSet) {
|
for (const pair of pairSet) {
|
||||||
if (!pair) continue;
|
|
||||||
console.info(`${pair.key} -> ${pair.val}`);
|
console.info(`${pair.key} -> ${pair.val}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,7 +87,6 @@ class ArrayHashMap {
|
|||||||
public print() {
|
public print() {
|
||||||
let pairSet = this.entries();
|
let pairSet = this.entries();
|
||||||
for (const pair of pairSet) {
|
for (const pair of pairSet) {
|
||||||
if (!pair) continue;
|
|
||||||
console.info(`${pair.key} -> ${pair.val}`);
|
console.info(`${pair.key} -> ${pair.val}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user