how to sort the container Array from std.container
ag0aep6g
anonymous at example.com
Wed Jun 6 14:46:56 UTC 2018
On 06/06/2018 04:20 PM, Flaze07 wrote:
> hmm, and sorry for asking more, what about removing an element from it ?
> I found no remove operation that can remove from the middle ( removeAny
> and removeBack both removes the latest element, linearRemove receive
> Array!uint...which don't know how to provide )
I think removeKey would be the container primitive for that. I don't
know if there's a reason why it isn't implemented for Array. Maybe it's
just an oversight.
You can use linearRemove like this:
----
import std.container.array: Array;
import std.stdio: writeln;
void main()
{
Array!int a = [1, 2, 100, 200, 300, 3, 4];
a.linearRemove(a[2 .. 5]);
/* Removes elements at indices 2, 3, and 4. */
writeln(a[]); /* Prints "[1, 2, 3, 4]". */
}
----
More information about the Digitalmars-d-learn
mailing list