Removing multiple elements from array

aldanor i.s.smirnov at gmail.com
Sat Dec 21 06:04:03 PST 2013


On Saturday, 21 December 2013 at 03:22:22 UTC, H. S. Teoh wrote:
> Unfortunately, while std.algorithm.remove does provide a way to 
> do this
> if the number of indices to remove are known beforehand, it 
> doesn't seem
> to be able to remove a dynamic list of indices. Probably an 
> enhancement
> request should be filed:
>
> 	http://d.puremagic.com/issues
>
> If the number of indices to remove are fixed, though, you can 
> do this:
>
> 	import std.algorithm : remove;
>  	int[] arr = [ ... ];
> 	int i1, i2, i3;  // indices to remove
> 	arr = arr.remove(i1, i2, i3);

Yes, this is exactly why I opened this thread initially, I 
noticed this functionality in .remove() and was native enough to 
assume there's a shortcut for batch removal with indices unknown 
in advance :)


More information about the Digitalmars-d-learn mailing list