Static Constructors

Saaa empty at needmail.com
Sat Oct 4 08:46:20 PDT 2008


>
> First one allocates new memory block.
> Second one attempts to erase an element in-place. Dupping, however, 
> allocates new memory, too.
> The best solution would be as follows:
>
> void eraseNth(ref T[] data, int n) {
>     data[n] = data[$-1];
>     data.length = data.length - 1;
> }

Yay, thats how I do it :) 




More information about the Digitalmars-d-learn mailing list