Return first index of {@code value} in {@code array}, or {@code -1} if
not found.
180053
public static <T> int indexOf(T[] array, T value) {
        for (int i = 0; i < array.length; i++) {
            if (array[i] == null) {
                if (value == null) return i;
            } else {
                if (value != null && array[i].equals(value)) return i;
            }
        }
        return -1;
    }
168784
public static Object getIndex(Object array, int index)
            throws UtilTargetError {
        Interpreter.debug("getIndex: ", array, ", index=", index);
        try {
            if ( array instanceof List )
                return ((List<?>) array).get(index);
            Object val = Array.get(array, index);
            return Primitive.wrap( val, Types.arrayElementType(array.getClass()) );
        } catch( IndexOutOfBoundsException e1 ) {
            int len = array instanceof List
                    ? ((List<?>) array).size()
                    : Array.getLength(array);
            throw new UtilTargetError("Index " + index
                    + " out-of-bounds for length " + len, e1);
        }
    }
1147584
public static int searchDescending(short[] shortArray, short value) { 
        int start = 0;
        int end = shortArray.length - 1;
        int middle = 0;
        
        while(start <= end) {
            middle = (start + end) >> 1;
        
            if(value == shortArray[middle]) {
                return middle;
            }
            
            if(value > shortArray[middle]) {
                end = middle - 1 ;
            }
            else {
                start = middle + 1;
            }
        }
                

        return -1;
    }
1275542
public int getIndexOfValue(String fieldName, Object value) {
		int ret = -1;
		Object val = value;
		if (value instanceof DomainObject)
			val = ((DomainObject)value).getRawObject();
		Object lst = getFieldValue(fieldName, true); // internal
		if (lst instanceof List<?>) {
			List<?> list = (List<?>)lst;
			for (int i = 0; i < list.size(); i++) {
				Object obj = list.get(i);
				if (obj.equals(val)) {
					ret = i;
					break;
				}
			}
		} else if (lst != null && lst.getClass().isArray()) {
			int len = Array.getLength(lst);
			for (int i = 0; i < len; i++) {
				Object obj = Array.get(lst, i);
				if (obj.equals(val)) {
					ret = i;
					break;
				}
			}
		} else {
			if (!getDomainObjectType().getFieldByName(fieldName).isListOrArray())
				throw new RuntimeException("field: [" + fieldName + "] is neither list nor array");
			if (lst == null)
				throw new RuntimeException("list or array field: [" + fieldName + "] is null");
		}
		return ret;
	}
479232
public static int indexOfNull (Object[] list)
    {
        if (list != null) {
            for (int ii=0, nn = list.length; ii < nn; ii++) {
                if (list[ii] == null) {
                    return ii;
                }
            }
        }
        return -1;
    }
925572
public static <T> T firstValue(List<T> list) {
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }
1182264
public static int search(byte[] byteArray, byte value) { 
        int start = 0;
        int end = byteArray.length - 1;
        int middle = 0;
        
        while(start <= end) {
            middle = (start + end) >> 1;
        
            if(value == byteArray[middle]) {
                return middle;
            }
            
            if(value < byteArray[middle]) {
                end = middle - 1 ;
            }
            else {
                start = middle + 1;
            }
        }
                

        return -1;
    }
76876
public static <T> T getFirst(T array[]){
        return array!=null && array.length>0 ? array[0] : null;
    }
492221
function (value, array) {
            if (util.isFn(array.indexOf)) {
                return array.indexOf(value);
            } else {
                return $.inArray(value, array);
            }
        }
1022840
function indexOf(arr, value, start) {
  start = start || 0;
  if (arr == null) {
    return -1;
  }
  var len = arr.length;
  var i = start < 0 ? len + start : start;
  while (i < len) {
    if (arr[i] === value) {
      return i;
    }
    i++;
  }
  return -1;
}
343663
public static int indexOf(double[] array, double val) {
        for (int i=0; i<array.length; i++) {
            if (array[i] == val) {
                return i;
            }
        }
        return -1;
    }
546468
public int indexOf(int[] sequence) {
        int index = -1;
        for (int i = 0; index == -1 && i <= currentSize - sequence.length;
             i++) {
            if (buffer[i] == sequence[0]) {
                boolean matches = true;
                for (int j = 1; matches && j < sequence.length; j++) {
                    if (buffer[i + j] != sequence[j]) {
                        matches = false;
                    }
                }
                if (matches) {
                    index = i;
                }
            }
        }
        return index;
    }
1274906
public static int indexOf (int[] values, int value)
    {
        int count = (values == null) ? 0 : values.length;
        for (int ii = 0; ii < count; ii++) {
            if (values[ii] == value) {
                return ii;
            }
        }
        return -1;
    }
1282420
public static <T> T getFirst(T[] objectArray)
    {
        if (ArrayIterate.notEmpty(objectArray))
        {
            return objectArray[0];
        }
        return null;
    }
807754
public static int findMaxIndex( int[] a ) {
		int max = a[0];
		int index = 0;

		for( int i = 1; i< a.length; i++ ) {
			int val = a[i];

			if( val > max ) {
				max = val;
				index = i;
			}
		}

		return index;
	}
979010
protected static int containsIndex(int[] is, int i) {
    for(int j = 0; j < is.length; j++) {
      if(i == is[j]) {
        return j;
      }
    }
    return -1;
  }
1122736
public int lookupIndex(short value) {
        for (int i=0; i<elements.length; i++) {
            if (elements[i] == value) {
                return i;
            }
        }
        return -1;
    }