Added indexOf() for float arrays.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@962 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user