Java Array Min Value minimum(char[] set)

Here you can find the source of minimum(char[] set)

Description

minimum

License

Apache License

Declaration

public static char[] minimum(char[] set) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static final int ENCODING_LENGTH = 128;

    public static char[] minimum(char[] set) { // [e, a, d, f, f, c, c, k, \s] -> {a, c, d, e, f, k, \0, \t}
        boolean[] book = emptyBook();
        for (char b : set) {
            book[b] = true;/*w w w.  j  a v a2s  . co m*/
        }
        return bookToSet(book, true);
    }

    private static boolean[] emptyBook() {
        boolean[] book = new boolean[ENCODING_LENGTH];
        for (int i = 0; i < book.length; i++) {
            book[i] = false;
        }
        return book;
    }

    private static char[] bookToSet(boolean[] book, boolean persistedFlag) {
        char[] newSet = new char[ENCODING_LENGTH];
        int i = 0;
        for (char j = 0; j < book.length; j++) {
            boolean e = book[j];
            if (e == persistedFlag) {
                newSet[i++] = j;
            }
        }
        return newSet;
    }
}

Related

  1. minElement(int[] array)
  2. minFastSort(double x[], int idx[], int n, int m)
  3. minFastSort(double[] x, int[] idx, int size)
  4. minIdx(int[] in)
  5. minIgnoreIndex(double[] array, int indexToIgnore)
  6. minimum(double[] list)
  7. minimum(float[] array)
  8. minimum(int... values)
  9. minimumDotProduct(int[] a, int[] b)