class PrimitiveIntCollections {

    public static int[] deduplicate(int[] values) {
        int unique = 0;
        for (int i = 0; i < values.length; i++) {
            int value = values[i];
            for (int j = 0; j < unique; j++) {
                if (value == values[j]) {
                    value = -1; // signal that this value is not unique
                    break; // we will not find more than one conflict
                }
            }
            if (value != -1) {   // this has to be done outside the inner loop, otherwise we'd never accept a single one...
                values[unique++] = values[i];
            }
        }
        return unique < values.length ? Arrays.copyOf(values, unique) : values;
    }

    private  PrimitiveIntCollections();

}