Deleting an element from an array
Jarrett Billingsley
jarrett.billingsley at gmail.com
Tue Feb 3 08:28:13 PST 2009
On Tue, Feb 3, 2009 at 10:54 AM, nobody <somebody at somewhere.com> wrote:
> Let's see if I understand memmove..
> The way it's used here, it copies the tail of an array onto that same array,
> only starting one index earlier, thus removing the undesired element?
> Neat.
Right.
> However I just realized that order does not matter in the array I'm using,
> so I guess I could use something like:
> arr[ind] = arr[$-1];
> arr.length = arr.length -1;
> Seeing how this only copies once, I'm guessing this is more efficient?
Way more efficient ;)
More information about the Digitalmars-d-learn
mailing list