Here you can find the source of countUnique(int[][] array)
private static int countUnique(int[][] array)
//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; } }