Arrays are sufficient for ArrayLists? Really??

Timon Gehr timon.gehr at gmx.ch
Mon May 16 12:53:38 PDT 2011


> In fact I even need to take that back. In order to work correctly, the
> function would have to iterate downwards. It _is_ indeed buggy, and I
> should stop emitting opinions when I'm short on time...
>
> Andrei

Whoops, you are right:

void removeAt(T)(ref T[] arr, size_t index)
{
   foreach (i, ref item; retro(arr[1 .. index+1]))
        item = arr[i - 1];
    arr = arr[1 .. $];
}

Timon


More information about the Digitalmars-d mailing list