class PrimitiveLongCollections {

    public static long[] deduplicate( long[] values )
    {
        int unique = 0;
        for ( int i = 0; i < values.length; i++ )
        {
            long 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  PrimitiveLongCollections();

}