Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadData.java @ 8139:1e8812b996bc
Sediment load: Remove simple tail recursive calls from SedimentLoadData.recursiveFindStations(). More carefully this time.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Tue, 26 Aug 2014 11:28:03 +0200 |
parents | bbad52b073a4 |
children | 369fbb28f5d0 |
comparison
equal
deleted
inserted
replaced
8138:8eb25cbfe242 | 8139:1e8812b996bc |
---|---|
391 private void recursiveFindStations( | 391 private void recursiveFindStations( |
392 double a, double b, | 392 double a, double b, |
393 int lo, int hi, | 393 int lo, int hi, |
394 Visitor visitor | 394 Visitor visitor |
395 ) { | 395 ) { |
396 if (lo > hi) { | 396 while (lo <= hi) { |
397 return; | 397 int mid = (lo+hi)/2; |
398 } | 398 Station st = stations[mid]; |
399 int mid = (lo+hi)/2; | 399 double station = st.getStation(); |
400 Station st = stations[mid]; | 400 if (station < a) { |
401 double station = st.getStation(); | 401 lo = mid+1; |
402 if (station < a) { | 402 } else if (station > b) { |
403 recursiveFindStations(a, b, mid+1, hi, visitor); | 403 hi = mid-1; |
404 } else if (station > b) { | 404 } else { |
405 recursiveFindStations(a, b, lo, mid-1, visitor); | 405 recursiveFindStations(a, b, lo, mid-1, visitor); |
406 } else { | 406 visitor.visit(st); |
407 recursiveFindStations(a, b, lo, mid-1, visitor); | 407 lo = mid+1; |
408 visitor.visit(st); | 408 } |
409 recursiveFindStations(a, b, mid+1, hi, visitor); | |
410 } | 409 } |
411 } | 410 } |
412 | 411 |
413 public static final Comparator<Load> LOAD_ID_CMP = new Comparator<Load>() { | 412 public static final Comparator<Load> LOAD_ID_CMP = new Comparator<Load>() { |
414 @Override | 413 @Override |