Java Array Min Value min(byte[] values)

Here you can find the source of min(byte[] values)

Description

Get the minimum value in an array subset

License

Open Source License

Parameter

Parameter Description
values the array to search

Return

the minimum value found in the array subset specified

Declaration

public static final byte min(byte[] values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     *//*  www .j ava  2 s  . co  m*/
    public static final byte min(byte[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final byte min(byte[] values, int offset, int length) {
        byte min = Byte.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final short min(short[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final short min(short[] values, int offset, int length) {
        short min = Short.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final char min(char[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final char min(char[] values, int offset, int length) {
        char min = Character.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final int min(int[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final int min(int[] values, int offset, int length) {
        int min = Integer.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final long min(long[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final long min(long[] values, int offset, int length) {
        long min = Long.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final float min(float[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final float min(float[] values, int offset, int length) {
        float min = Float.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @return the minimum value found in the array subset specified
     */
    public static final double min(double[] values) {
        return min(values, 0, values.length);
    }

    /** Get the minimum value in an array subset
     * @param values the array to search
     * @param offset the offset into the array at which to start searching
     * @param length the number of values to search
     * @return the minimum value found in the array subset specified
     */
    public static final double min(double[] values, int offset, int length) {
        double min = Double.MAX_VALUE;
        int offLen = offset + length;
        for (int i = offset; i < offLen; i++) {
            if (min > values[i]) {
                min = values[i];
            }
        }
        return min;
    }
}

Related

  1. maxMinValues(int[] array)
  2. maxMinValues(long[] array)
  3. maxValue(long[] array)
  4. min(byte[] arr)
  5. min(byte[] array)
  6. min(double values[], boolean[] mask)
  7. min(double values[], int size)
  8. min(double... a)
  9. min(double... args)