From 8adbb71ad92e3b06cf3781a27d8a5dad60cc6af8 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 4 Apr 2006 17:22:35 +0000 Subject: [PATCH] Added a needed method, since I have write permission to samskivert. git-svn-id: https://samskivert.googlecode.com/svn/trunk@1806 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- src/java/com/samskivert/util/ArrayUtil.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/java/com/samskivert/util/ArrayUtil.java b/src/java/com/samskivert/util/ArrayUtil.java index a00aae43..4194e9ba 100644 --- a/src/java/com/samskivert/util/ArrayUtil.java +++ b/src/java/com/samskivert/util/ArrayUtil.java @@ -30,6 +30,24 @@ import java.util.Random; */ public class ArrayUtil { + /** + * 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 (byte[] values, byte value) + { + int count = (values == null) ? 0 : values.length; + for (int ii = 0; ii < count; ii++) { + if (values[ii] == value) { + return ii; + } + } + return -1; + } + /** * Looks for an element that is equal to the supplied value and * returns its index in the array.