Changeset 175 for trunk/JavaHelperLib/src/de/ugoe/cs/util/ArrayTools.java
- Timestamp:
- 09/09/11 23:52:51 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaHelperLib/src/de/ugoe/cs/util/ArrayTools.java
r1 r175 1 1 package de.ugoe.cs.util; 2 2 3 /** 4 * <p> 5 * Helper class that provides methods to simplify working with arrays. 6 * </p> 7 * 8 * @author Steffen Herbold 9 * @version 1.0 10 */ 3 11 final public class ArrayTools { 4 12 5 13 /** 6 14 * <p> 7 * Finds the first occur ence of an object inside an array.15 * Finds the first occurrence of an object inside an array. 8 16 * </p> 9 17 * <p> 10 * In case {@code other==null}, the first occurence of a {@code null} value in the array is returned. 18 * In case {@code other==null}, the first occurrence of a {@code null} value 19 * in the array is returned. 11 20 * </p> 12 * 13 * @param array the array 14 * @param other the object 21 * 22 * @param array 23 * the array 24 * @param other 25 * the object 15 26 * @return index of the object if found, -1 otherwise 16 27 */ 17 28 public static int findIndex(Object[] array, Object other) { 18 29 int retVal = -1; 19 for ( int i=0 ; i<array.length && retVal==-1 ; i++) {20 if ( other!=null) {21 if ( array[i]!=null && array[i].equals(other)) {30 for (int i = 0; i < array.length && retVal == -1; i++) { 31 if (other != null) { 32 if (array[i] != null && array[i].equals(other)) { 22 33 retVal = i; 23 34 } 24 35 } else { 25 if ( array[i]==null) {36 if (array[i] == null) { 26 37 retVal = i; 27 38 }
Note: See TracChangeset
for help on using the changeset viewer.