Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/SedimentLoadFacet.java @ 7254:fe32a7f9655e
Reduce usage of careless 'for (int i = 0; i < x.size(); i++)' pattern.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Sat, 05 Oct 2013 17:52:16 +0200 |
parents | 274948f91dd6 |
children | aab63784a80f |
comparison
equal
deleted
inserted
replaced
7253:90a3bcd8060a | 7254:fe32a7f9655e |
---|---|
151 // Find station via its station (km). | 151 // Find station via its station (km). |
152 // TODO use a binarySearch instead of linear absdiff approach | 152 // TODO use a binarySearch instead of linear absdiff approach |
153 int i = 0; | 153 int i = 0; |
154 for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) { | 154 for (Map.Entry<Double, Double> kmLoad: sortedKmLoad.entrySet()) { |
155 boolean matchFound = false; | 155 boolean matchFound = false; |
156 for (int k = 0; k < stations.size(); k++) { | 156 for (int k = 0, S = stations.size(); k < S; k++) { |
157 MeasurementStation station = stations.get(k); | 157 MeasurementStation station = stations.get(k); |
158 if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON) { | 158 if (Math.abs(station.getStation() - kmLoad.getKey()) < EPSILON) { |
159 // Value has been taken at measurement station. | 159 // Value has been taken at measurement station. |
160 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; | 160 values[0][i*3] = station.getRange().getA().doubleValue() + EPSILON; |
161 values[1][i*3] = kmLoad.getValue(); | 161 values[1][i*3] = kmLoad.getValue(); |
162 double endValue = 0d; | 162 double endValue = 0d; |
163 // Valid until next measurements stations begin of range, | 163 // Valid until next measurements stations begin of range, |
164 // or end of current range if last value. | 164 // or end of current range if last value. |
165 if (k+2 <= stations.size()) { | 165 if (k+2 <= S) { |
166 endValue = stations.get(k+1).getRange().getA().doubleValue(); | 166 endValue = stations.get(k+1).getRange().getA().doubleValue(); |
167 } | 167 } |
168 else { | 168 else { |
169 endValue = station.getRange().getB().doubleValue(); | 169 endValue = station.getRange().getB().doubleValue(); |
170 } | 170 } |