diff --git a/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java b/projects/samskivert/src/java/com/samskivert/util/ArrayUtil.java index b4bd709c..bfe70a0e 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.20 2002/12/03 23:55:52 shaper Exp $ +// $Id: ArrayUtil.java,v 1.21 2002/12/05 22:11:03 shaper Exp $ // // samskivert library - useful routines for java programs // Copyright (C) 2001 Walter Korman @@ -127,6 +127,25 @@ public class ArrayUtil return maxes; } + /** + * Looks for an element that is equal to the supplied value and + * returns its index in the array. + * + * @return the index of the first matching value if one was found, -1 + * otherwise. + */ + public static int indexOf (float[] values, float value) + { + int idx = -1; + int count = (values == null) ? 0 : values.length; + for (int ii = 0; ii < count; ii++) { + if (values[ii] == value) { + return ii; + } + } + return idx; + } + /** * Reverses the elements in the given array. *