Java Array Unique countUnique(int[][] array)

Here you can find the source of countUnique(int[][] array)

Description

count Unique

License

Apache License

Declaration

private static int countUnique(int[][] array) 

Method Source Code

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

import java.util.*;

public class Main {
    private static final int ARRAY_MAX = Integer.MAX_VALUE - 10;

    private static int countUnique(int[][] array) {
        if (array.length == 0) {
            return 0;
        }/*from w  ww.ja  v a2  s. c  o  m*/

        BitSet values = new BitSet(ARRAY_MAX);

        int count = 1;
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length - 1; j++) {
                if (!values.get(array[i][j])) {
                    count++;
                    values.set(array[i][j]);
                }
            }
        }
        return count;
    }
}

Related

  1. getUniqueIDsArray(int[] idArray, String ids, String seperator)
  2. getUniqueItems(final String[] allItems, final String newItem, final int maxItems)
  3. getUniqueWords(String[] input)
  4. invertRelabeling(int[] relabeling, int[] uniqueVars, int maxVarNum)