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

doublemaxAbs(double[] a, int begin, int end)
max Abs
double max = Math.abs(a[begin]);
for (int i = begin + 1; i < end; i++) {
    if (Math.abs(a[i]) > max) {
        max = Math.abs(a[i]);
return max;
floatmaxAbs(float[] a, int off, int length)
max Abs
final int stop = off + length;
float f1 = 0f, f2;
while (off < stop) {
    f2 = Math.abs(a[off++]);
    if (f2 > f1)
        f1 = f2;
return f1;
...
doublemaxarr(double[] a)
maxarr
double max = a[0];
for (int i = 1; i < a.length; i++)
    if (a[i] > max)
        max = a[i];
return max;
doublemaxArray(double[] input)
max Array
assert ((input != null) && (input.length > 0)) : "Your array is empty.";
double temp = input[0];
for (int index = 0; index < input.length; index++)
    temp = temp < input[index] ? input[index] : temp;
return temp;
intmaxArray(int[] arr)
max Array
int retVal = arr[0];
for (int i = 1; i < arr.length; i++) {
    if (arr[i] > retVal)
        retVal = arr[i];
return retVal;
int[]maxBetween(int[] arr1, int[] arr2)
Returns an array of identical shape containing the maximum of the values between each corresponding index.
int[] retVal = new int[arr1.length];
for (int i = 0; i < arr1.length; i++) {
    retVal[i] = Math.max(arr1[i], arr2[i]);
return retVal;
intmaxbits(int[] i, int pos, int length)
get the msb of all the elements between the range of pos and length of the input list
int mask = 0;
for (int k = pos; k < pos + length; ++k)
    mask |= i[k];
return bits(mask);
intmaxbits32(int[] i, int pos)
get the msb of 32 elements of the input list
int mask = i[pos];
mask |= i[pos + 1];
mask |= i[pos + 2];
mask |= i[pos + 3];
mask |= i[pos + 4];
mask |= i[pos + 5];
mask |= i[pos + 6];
mask |= i[pos + 7];
...
intmaxCommonLeadingWhitespaceForAll(String[] strings)
Determine the maximum number of common leading whitespace characters the strings share in the same sequence.
int shortest = lengthOfShortestIn(strings);
if (shortest == 0)
    return 0;
char[] matches = new char[shortest];
String str;
for (int m = 0; m < matches.length; m++) {
    matches[m] = strings[0].charAt(m);
    if (!Character.isWhitespace(matches[m]))
...
intmaxcount(int[] vals, int max, int maxcount)
maxcount
for (int i = 0; i < vals.length; i++) {
    int v = vals[i];
    if (v > max) {
        max = v;
        maxcount = 1;
    } else if (v == max) {
        maxcount++;
return maxcount;