Added getMinValue().
git-svn-id: https://samskivert.googlecode.com/svn/trunk@895 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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
|
// samskivert library - useful routines for java programs
|
||||||
// Copyright (C) 2001 Walter Korman
|
// Copyright (C) 2001 Walter Korman
|
||||||
@@ -48,6 +48,23 @@ public class ArrayUtil
|
|||||||
return max;
|
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
|
* 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
|
* have the maximum value in the array, or a zero-length array if the
|
||||||
|
|||||||
Reference in New Issue
Block a user