Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/QRangeTree.java @ 5423:f4fd64a4d502
Fix Wstcalculation for non monotonous values.
Patch written and provided by Sascha Teichmann
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 26 Mar 2013 11:39:03 +0100 |
parents | 14db045d6368 |
children |
comparison
equal
deleted
inserted
replaced
5422:eb7a3f58bdd6 | 5423:f4fd64a4d502 |
---|---|
265 | 265 |
266 parent.left = buildTree(nodes, lo, mid-1); | 266 parent.left = buildTree(nodes, lo, mid-1); |
267 parent.right = buildTree(nodes, mid+1, hi); | 267 parent.right = buildTree(nodes, mid+1, hi); |
268 | 268 |
269 return parent; | 269 return parent; |
270 } | |
271 | |
272 public double averageQ() { | |
273 double sum = 0d; | |
274 int n = 0; | |
275 for (Node node = head(); node != null; node = node.next) { | |
276 sum += node.q; | |
277 ++n; | |
278 } | |
279 return sum/n; | |
280 } | |
281 | |
282 public double maxQ() { | |
283 double max = -Double.MAX_VALUE; | |
284 for (Node node = head(); node != null; node = node.next) { | |
285 if (node.q > max) { | |
286 max = node.q; | |
287 } | |
288 } | |
289 return max; | |
270 } | 290 } |
271 | 291 |
272 public double findQ(double pos) { | 292 public double findQ(double pos) { |
273 return root != null ? root.findQ(pos) : Double.NaN; | 293 return root != null ? root.findQ(pos) : Double.NaN; |
274 } | 294 } |