From f8cf165235a5aeb9de71d092ba46154ce2445f73 Mon Sep 17 00:00:00 2001 From: shaper Date: Fri, 8 Nov 2002 02:34:54 +0000 Subject: [PATCH] Added getMinValue(). git-svn-id: https://samskivert.googlecode.com/svn/trunk@895 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ArrayUtil.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java index ad78a7e4..1b4c3e24 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java +++ b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java @@ -1,5 +1,5 @@ // -// $Id: ArrayUtil.java,v 1.17 2002/09/19 23:37:40 shaper Exp $ +// $Id: ArrayUtil.java,v 1.18 2002/11/08 02:34:54 shaper Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Walter Korman @@ -48,6 +48,23 @@ public class ArrayUtil return max; } + /** + * Returns the minimum value in the given array of values, or {@link + * Integer#MAX_VALUE} if the array is null or zero-length. + */ + public static int getMinValue (int[] values) + { + int min = Integer.MAX_VALUE; + int vcount = (values == null) ? 0 : values.length; + for (int ii = 0; ii < vcount; ii++) { + if (values[ii] < min) { + // new min + min = values[ii]; + } + } + return min; + } + /** * Returns an array of the indexes in the given array of values that * have the maximum value in the array, or a zero-length array if the