summaryrefslogtreecommitdiffstats
path: root/Heap.cs
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2021-03-27 19:02:02 +0000
committerToby Vincent <tobyv13@gmail.com>2021-03-27 19:02:14 +0000
commitb73fed3952026be02ac577cc7e4a577a740f3498 (patch)
tree87b09d88e51f2f71924653fca4459d39497757e8 /Heap.cs
parent960dc370960a97a7bebb113cf73d89e168cd6f3e (diff)
more work
Diffstat (limited to 'Heap.cs')
-rwxr-xr-xHeap.cs8
1 files changed, 4 insertions, 4 deletions
diff --git a/Heap.cs b/Heap.cs
index 5c11217..439f278 100755
--- a/Heap.cs
+++ b/Heap.cs
@@ -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)