[Dive4elements-commits] [PATCH 10 of 10] DoubleUtil: New function to find max in an double array

Wald Commits scm-commit at wald.intevation.org
Wed Oct 31 14:09:10 CET 2012


# HG changeset patch
# User Felix Wolfsteller <felix.wolfsteller at intevation.de>
# Date 1351689213 -3600
# Node ID 64528d2a89c4446c0bfd46a9dd267cbdecac8383
# Parent  ff83ec9b4c0b7c961fd631d2ac9d2fb0b2752d63
DoubleUtil: New function to find max in an double array.

diff -r ff83ec9b4c0b -r 64528d2a89c4 flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Wed Oct 31 14:09:36 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/DoubleUtil.java	Wed Oct 31 14:13:33 2012 +0100
@@ -199,5 +199,15 @@
         }
         return true;
     }
+
+
+    /** In an array of doubles, search and return the maximum value. */
+    public static final double maxInArray(double[] values) {
+        double max = - Double.MAX_VALUE;
+        for (double d: values) {
+            if (d > max) max = d;
+        }
+        return max;
+    }
 }
 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :


More information about the Dive4elements-commits mailing list