Here you can find the source of maxDistance(byte[] array, int maxDistance)
Parameter | Description |
---|---|
array | a parameter |
maxDistance | a parameter |
public static boolean maxDistance(byte[] array, int maxDistance)
//package com.java2s; public class Main { /**//from w w w. j a va 2 s . c o m * Returns true when the max distance between values in the array is NOT larger then the given value * @param array * @param maxDistance * @return */ public static boolean maxDistance(byte[] array, int maxDistance) { if (array == null || array.length == 0) { return true; } int min = array[0]; int max = array[0]; for (byte value : array) { min = Math.min(value, min); max = Math.max(value, max); if (Math.abs(min - max) > maxDistance) { return false; } } return true; } public static double max(double[] array) { double max = Double.NEGATIVE_INFINITY; for (int i = 0; i < array.length; i++) { if (array[i] > max) { max = array[i]; } } return max; } public static float max(float[] array) { float max = Float.NEGATIVE_INFINITY; for (int i = 0; i < array.length; i++) { if (array[i] > max) { max = array[i]; } } return max; } }