List of utility methods to do Array Min Value
int | findMin(int[] workArray, int idx) find Min return findMin2(workArray, idx, workArray[idx]);
|
int | findMin(String[] strs) find Min int result = 0; int minLen = 1000; for (int i = 0; i < strs.length; i++) { if (strs[i].length() < minLen) { minLen = strs[i].length(); result = i; return result; |
int | findMin2(int[] workArray, int idx, int min) find Min if (idx <= 0) return min; return findMin2(workArray, idx - 1, Math.min(min, workArray[idx - 1])); |
Map | findMinAndMax(double[] array) find Min And Max double min = Double.MAX_VALUE; double max = Double.MIN_VALUE; for (int i = 0; i < array.length; i++) { if (array[i] < min) { min = array[i]; if (array[i] > max) { max = array[i]; ... |
float[] | findMinAndMax(float[] buffer, int pixelStride, int numBands) find Min And Max float min = Float.MAX_VALUE; float max = -Float.MAX_VALUE; for (int i = 0; i < buffer.length; i += numBands) { for (int j = 0; j < pixelStride; ++j) { float value = buffer[i + j]; if (!Float.isInfinite(value)) { if (value < min) min = value; ... |
int | findMinDiff(double[] values) Find the 2 values with the smallest difference between them. double minDiff; int minIdx; if (values.length < 2) { throw new IllegalArgumentException("Array length must be >= 2"); minIdx = 0; minDiff = values[1] - values[0]; for (int i = 1; i < (values.length - 1); i++) { ... |
int | findMinIndex(double[] arr, int offset, int length) find Min Index int minIndex = -1; double minValue = Double.MAX_VALUE; int endIdx = offset + length; for (int i = offset; i < endIdx; i++) { if (arr[i] < minValue) { minValue = arr[i]; minIndex = i; return minIndex; |
int | maxLength(T[] array) max Length int re = 0; if (null != array) for (CharSequence s : array) if (null != s) re = Math.max(re, s.length()); return re; |
int[] | maxMinValues(int[] array) Returns the maximum/minimum values of an input array. if (array.length == 0) { throw new NoSuchElementException("Empty array"); int maxValue = array[0]; int minValue = array[0]; for (int i = 1; i < array.length; i++) { if (array[i] > maxValue) maxValue = array[i]; ... |
long[] | maxMinValues(long[] array) Returns the maximum/minimum values of an input array. if (array.length == 0) { throw new NoSuchElementException("Empty array"); long maxValue = array[0]; long minValue = array[0]; for (int i = 1; i < array.length; i++) { if (array[i] > maxValue) { maxValue = array[i]; ... |