Java Utililty Methods Array Max Value

List of utility methods to do Array Max Value

Description

The list of methods to do Array Max Value are organized into topic(s).

Method

intmaxElementIndex(final double[] array, final int endIndex)
max Element Index
if (array == null || array.length == 0)
    throw new IllegalArgumentException("Array cannot be null!");
int maxI = 0;
for (int i = 1; i < endIndex; i++) {
    if (array[i] > array[maxI])
        maxI = i;
return maxI;
...
intmaxFloorDiv(int c, int... vals)
max Floor Div
assert (vals.length > 0);
assert (vals[0] != 0);
int res = Integer.MIN_VALUE;
for (int i = 0; i < vals.length; i++) {
    assert (vals[i] != 0);
    int tmp = floorDiv(c, vals[i]);
    if (tmp > res)
        res = tmp;
...
doublemaxFromDoubleArray(double[] arr)
max From Double Array
double max = Double.NEGATIVE_INFINITY;
for (double d : arr) {
    if (d > max)
        max = d;
return max;
intmaxIdx(int[] in)
max Idx
int out = in[0];
for (int i = 1; i < in.length; i++) {
    if (in[i] > in[out]) {
        out = i;
return out;
doublemaximum(double[] list)
Returns the maximum double in the list of doubles.
double max = list[0];
for (int i = 1; i < list.length; ++i)
    if (list[i] > max)
        max = list[i];
return max;
floatmaximum(float[] array)
Find the maximum element in an array
if (array.length <= 0)
    throw new IllegalArgumentException("The array is empty");
float max = array[0];
for (int i = 1; i < array.length; i++)
    if (array[i] > max)
        max = array[i];
return max;
doublemaximumDouble(double... values)
maximum Double
double ret = values[0];
for (int i = 1; i < values.length; i++) {
    ret = Math.max(ret, values[i]);
return ret;
intmaximumOf(final int[] array)
maximum Of
int maximum = array[0];
for (int i = 1; i != array.length; i++)
    if (maximum < array[i])
        maximum = array[i];
return maximum;
doublemaxIn(double[] array)
max In
double max = -Double.MAX_VALUE;
for (double val : array) {
    max = max < val ? val : max;
return max;
intmaxInArray(int[] src)
max In Array
int max = src[0];
for (int a : src) {
    if (a > max)
        max = a;
return max;