Timon: > What about: void removeAt(T)(ref T[] arr, size_t index) { foreach (i, ref item; arr[1 .. index+1]) item = arr[i - 1]; arr = arr[1 .. $]; //note how no valid data is beyond the end of the array }
Clever, but if you do this with a big enough number of items, you'll exhaust all memory. Be careful. :P Steven: > For the OP, you may want to consider using ArrayList from dcollections, which supports removing an individual or range of elements, or using foreach to purge the list. Note that this class does call assumeSafeAppend on its data storage since it can make more assumptions. Ah, seems to be what I need. I guess I was also trying to argue this should really be part of the language too, though (not just Phobos), given that concatenation and even hashtables are also part of the language. It seems to be missing badly. :\