Here you can find the source of min(T[] inputArray, int i, int i0)
Parameter | Description |
---|---|
T | Type that implements Comparable |
inputArray | An array of elements of type Comparable |
i | The starting index |
i0 | The ending index |
private static <T extends Comparable> int min(T[] inputArray, int i, int i0)
//package com.java2s; //License from project: Open Source License public class Main { /**//from www .jav a 2 s. c o m * Finds the minimum element between to specified indexes of an array * * @param <T> Type that implements Comparable * @param inputArray An array of elements of type Comparable * @param i The starting index * @param i0 The ending index * @return The smallest index between the two specified input indices. */ private static <T extends Comparable> int min(T[] inputArray, int i, int i0) { int smallestIndex = i; //set default smallest index to i i++; //increment i so that we don't compare index to itself while (i <= i0) { //loop through range specified by index params //if object in index is smaller than specified object... if (inputArray[i].compareTo(inputArray[smallestIndex]) < 0) { smallestIndex = i; //set lowIndex to that of new smaller object } i++; } return smallestIndex; } }