(svn r13459) [NoAI] -Fix: final fixes in binary_heap noai
authortruebrain
Tue, 10 Jun 2008 23:02:23 +0000
branchnoai
changeset 10908 429195fd03f2
parent 10907 6e0aecaf6e4c
child 10909 3c573e607b60
(svn r13459) [NoAI] -Fix: final fixes in binary_heap
bin/ai/library/queue/binary_heap/main.nut
bin/ai/regression/regression.txt
--- 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