changeset 3126:fe9be7ccc5e8

Fixed binary search in Parameters. flys-artifacts/trunk@4727 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 20 Jun 2012 15:03:29 +0000
parents 070b76fbae46
children 71484036b6ae
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java
diffstat 2 files changed, 9 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Wed Jun 20 14:24:52 2012 +0000
+++ b/flys-artifacts/ChangeLog	Wed Jun 20 15:03:29 2012 +0000
@@ -1,3 +1,8 @@
+2012-06-20  Raimund Renkert <raimund.renkert@intevation.de>
+
+	* src/main/java/de/intevation/flys/artifacts/model/Parameters.java:
+	  Fixed binary search.
+
 2012-06-20	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/artifacts/model/Parameters.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java	Wed Jun 20 14:24:52 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Parameters.java	Wed Jun 20 15:03:29 2012 +0000
@@ -164,11 +164,11 @@
 
         TDoubleArrayList column = columns[columnIndex];
         int lo = 0, hi = column.size()-1;
-        while (lo <= hi) {
-            int mid = (lo + hi) >>> 1;
+        while (hi >= lo) {
+            int mid = (lo + hi) >> 1;
             double v = column.getQuick(mid);
-            if      (v < vl) hi = mid - 1;
-            else if (v > vh) lo = mid + 1;
+            if      (v < vl) lo = mid + 1;
+            else if (v > vh) hi = mid - 1;
             else             return mid;
         }
 

http://dive4elements.wald.intevation.org