The list of methods to do Array Unique are organized into topic(s).
int
countUnique(int[][] array) count Unique
if (array.length == 0) {
return 0;
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])) {
...
String[]
getUniqueWords(String[] input) Find all unique words in an array of words
if (input == null) {
return new String[0];
} else {
Set result = new TreeSet();
for (int i = 0; i < input.length; i++) {
result.add(input[i]);
return (String[]) result.toArray(new String[result.size()]);
...
double[]
unique(double[] in) Same behaviour as mathlab unique.
Arrays.sort(in);
int n = in.length;
double[] temp = new double[n];
temp[0] = in[0];
int count = 1;
for (int i = 1; i < n; i++) {
if (Double.compare(in[i], in[i - 1]) != 0) {
temp[count++] = in[i];
...
int[]
unique(int[] a, int aLen, int[] b, int bLen) Returns array which is the union of two arrays (array of elements contained in any of provided arrays).
assert a != null;
assert b != null;
assert isIncreasingArray(a, aLen);
assert isIncreasingArray(b, bLen);
int[] res = new int[aLen + bLen];
int resLen = 0;
int i = 0;
int j = 0;
...
int[]
unique(int[] array) Returns the same values of the input array but with no repetitions.
Set<Integer> uniqueSet = new LinkedHashSet<Integer>();
for (int i = 0; i < array.length; i++)
uniqueSet.add(array[i]);
return toArray(uniqueSet);
Object[]
unique(Object[] elements) Return a set (array of unique objects).
Hashtable h = new Hashtable();
Object o = new Object();
for (int i = 0; i < elements.length; i++) {
h.put(elements[i], o);
Object[] el2 = new Object[h.size()];
Enumeration e = h.keys();
int i = 0;
...
int[]
uniqueInts(int[] ints) returns the unique values from the given int array in sort order.
Arrays.sort(ints);
int duplicateCount = 0;
for (int i = 1; i < ints.length; i++) {
if (ints[i] == ints[i - 1]) {
duplicateCount++;
if (duplicateCount == 0) {
...