Here you can find the source of minIndex(float[] arr)
Parameter | Description |
---|---|
arr | array of floats |
public static int minIndex(float[] arr)
//package com.java2s; public class Main { /**// w ww . j a v a 2 s .c o m * Returns the index to the smallest value in the array * * @param arr array of floats * @return the index */ public static int minIndex(float[] arr) { float min = Float.MAX_VALUE; int index = 0; for (int i = 0; i < arr.length; i++) { if (arr[i] < min) { min = arr[i]; index = i; } } return index; } /** * Returns the index to the smallest value in the array * * @param dsqout array of ints * @return the index */ public static int minIndex(int[] dsqout) { int min = Integer.MAX_VALUE; int index = 0; for (int i = 0; i < dsqout.length; i++) { if (dsqout[i] < min) { min = dsqout[i]; index = i; } } return index; } /** * Returns the index to the smallest value in the array * * @param dsqout array of longs * @return the index */ public static int minIndex(long[] dsqout) { long min = Long.MAX_VALUE; int index = 0; for (int i = 0; i < dsqout.length; i++) { if (dsqout[i] < min) { min = dsqout[i]; index = i; } } return index; } /** * Returns the index to the smallest value in the array * * @param dsqout array of byte * @return the index */ public static int minIndex(byte[] dsqout) { byte min = Byte.MAX_VALUE; int index = 0; for (int i = 0; i < dsqout.length; i++) { if (dsqout[i] < min) { min = dsqout[i]; index = i; } } return index; } /** * Returns the index to the smallest value in the array * * @param dsqout array of short * @return the index */ public static int minIndex(short[] dsqout) { short min = Short.MAX_VALUE; int index = 0; for (int i = 0; i < dsqout.length; i++) { if (dsqout[i] < min) { min = dsqout[i]; index = i; } } return index; } /** * Returns the index to the smallest value in the array * * @param dsqout array of double * @return the index */ public static int minIndex(double[] dsqout) { double min = Double.MAX_VALUE; int index = 0; for (int i = 0; i < dsqout.length; i++) { if (dsqout[i] < min) { min = dsqout[i]; index = i; } } return index; } }