diff options
author | Toby Vincent <tobyv13@gmail.com> | 2021-03-27 19:02:02 +0000 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2021-03-27 19:02:14 +0000 |
commit | b73fed3952026be02ac577cc7e4a577a740f3498 (patch) | |
tree | 87b09d88e51f2f71924653fca4459d39497757e8 /Heap.cs | |
parent | 960dc370960a97a7bebb113cf73d89e168cd6f3e (diff) |
more work
Diffstat (limited to 'Heap.cs')
-rwxr-xr-x | Heap.cs | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -40,8 +40,8 @@ namespace PriorityQueue Array[other] = temp;
}
- protected bool IsMoreSignificant(T that, T other) =>
- that.CompareTo(other) * (IsMin ? -1 : 1) > 0;
+ protected int CompareKey(T that, T other) =>
+ that.CompareTo(other) * (IsMin ? -1 : 1);
// build local heap
protected void Heapify(int index)
@@ -50,10 +50,10 @@ namespace PriorityQueue int left = 2 * index + 1;
int right = 2 * index + 2;
- if (left <= HeapSize && IsMoreSignificant(Array[left], Array[sig]))
+ if (left <= HeapSize && CompareKey(Array[left], Array[sig]) > 0)
sig = left;
- if (right <= HeapSize && IsMoreSignificant(Array[right], Array[sig]))
+ if (right <= HeapSize && CompareKey(Array[right], Array[sig]) > 0)
sig = right;
if (sig != index)
|