(svn r13457) [NoAI] -Fix: fix the binary heap implementation to ... remain a valid binary heap tree :) noai
authortruebrain
Tue, 10 Jun 2008 22:32:48 +0000
branchnoai
changeset 10906 aebd9a1f401e
parent 10904 3070af6d1d25
child 10907 6e0aecaf6e4c
(svn r13457) [NoAI] -Fix: fix the binary heap implementation to ... remain a valid binary heap tree :)
bin/ai/library/queue/binary_heap/main.nut
--- a/bin/ai/library/queue/binary_heap/main.nut	Tue Jun 10 21:51:01 2008 +0000
+++ b/bin/ai/library/queue/binary_heap/main.nut	Tue Jun 10 22:32:48 2008 +0000
@@ -63,7 +63,7 @@
 
 	local hole;
 	/* Find the point of insertion */
-	for (hole = this._count - 1; hole > 0 && priority < this._queue[hole / 2][1]; hole /= 2)
+	for (hole = this._count - 1; hole > 0 && priority <= this._queue[hole / 2][1]; hole /= 2)
 		this._queue[hole] = this._queue[hole / 2];
 	/* Insert new pair */
 	this._queue[hole] = [item, priority];