[PATCH] Another fix for find stations in sediment load

Wald Commits scm-commit at wald.intevation.org
Mon Aug 25 17:14:52 CEST 2014


# HG changeset patch
# User Sascha L. Teichmann <teichmann at intevation.de>
# Date 1408979689 -7200
# Node ID 8c5eb9edc3f31c7ee8de65058ed56684d443bf38
# Parent  353f93d5d9f78af0516430998489e98a8e995a27
Another fix for find stations in sediment load.

diff -r 353f93d5d9f7 -r 8c5eb9edc3f3 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Mon Aug 25 16:04:35 2014 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java	Mon Aug 25 17:14:49 2014 +0200
@@ -391,19 +391,20 @@
         int lo, int hi,
         Visitor visitor
     ) {
-        while (lo <= hi) {
-            int mid = (lo+hi)/2;
-            Station st = stations[mid];
-            double station = st.getStation();
-            if (station < a) {
-                hi = mid-1;
-            } else if (station > b) {
-                lo = mid+1;
-            } else {
-                recursiveFindStations(a, b, lo, mid-1, visitor);
-                visitor.visit(st);
-                lo = mid+1;
-            }
+        if (lo > hi) {
+            return;
+        }
+        int mid = (lo+hi)/2;
+        Station st = stations[mid];
+        double station = st.getStation();
+        if (station < a) {
+            recursiveFindStations(a, b, mid+1, hi)
+        } else if (station > b) {
+            recursiveFindStations(a, b, lo, mid-1)
+        } else {
+            recursiveFindStations(a, b, lo, mid-1, visitor);
+            visitor.visit(st);
+            recursiveFindStations(a, b, mid+1, hi, visitor);
         }
     }
 


More information about the Dive4Elements-commits mailing list