Templated Lists
Ali Çehreli via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jun 16 17:28:50 PDT 2017
On 06/16/2017 05:02 PM, Jolly James wrote:
>>> I am looking for something similar to C#'s generic list.
> Thx, but I do not need to mix different types (using variant).
If I did well on my quick research, C#'s generic lists are exactly that. :)
> Assuming I use simply an dynamic array, how does one remove an
> specific item?
With std.algorithm.remove:
import std.algorithm;
void main() {
auto arr = [ 1, 2, 3, 4, 5, 6 ];
arr = arr.remove(5); // Removes element at index 3
assert(arr == [ 1, 2, 3, 4, 5 ]);
arr = arr.remove!(e => e % 2); // Removes elements with odd values
assert(arr == [ 2, 4 ]);
}
Ali
More information about the Digitalmars-d
mailing list