the input array
an array with only unique elements
Tests out using the uniqueness method
// Empty or 1 elem should not re-allocate int[] vals = []; int[] newVals = unique(vals); assert(vals.ptr == newVals.ptr); vals = [1]; newVals = unique(vals); assert(vals.ptr == newVals.ptr); // Copy triggering cases vals = [1,1]; newVals = unique(vals); assert(newVals == [1]);
Returns a version of the input array with only unique elements.
If the input array's length is 0 or 1 then it is immediately returned as an optimization.