--- a/bin/ai/library/queue/binary_heap/main.nut Tue Jun 10 22:35:13 2008 +0000
+++ b/bin/ai/library/queue/binary_heap/main.nut Tue Jun 10 23:02:23 2008 +0000
@@ -118,10 +118,10 @@
local tmp = this._queue[0];
/* Start switching parent and child until the tree is restored */
- while (hole * 2 <= this._count) {
+ while (hole * 2 < this._count + 1) {
local child = hole * 2;
- if (child != this._count && this._queue[child][1] < this._queue[child - 1][1]) child++;
- if (this._queue[child - 1][1] >= tmp[1]) break;
+ if (child != this._count && this._queue[child][1] <= this._queue[child - 1][1]) child++;
+ if (this._queue[child - 1][1] > tmp[1]) break;
this._queue[hole - 1] = this._queue[child - 1];
hole = child;
--- a/bin/ai/regression/regression.txt Tue Jun 10 22:35:13 2008 +0000
+++ b/bin/ai/regression/regression.txt Tue Jun 10 23:02:23 2008 +0000
@@ -5733,9 +5733,9 @@
Count(): 9
Peek(): 1
Pop(): 1
+ Pop(): 3
Pop(): 4
Pop(): 2
- Pop(): 3
Pop(): 1
Pop(): 5
Pop(): 6