On Sun, 12 Dec 2010 20:43:12 -0500
"Andrej M." <[email protected]> wrote:
> I can't seem to find an easy remove method in std.algorithm that takes an
> object and a range (an array in this case) and removes any matches from the
> range. I'm using this snippet for now:
>
> private DrawingElement[] elements;
>
> public override void Remove(DrawingElement d)
> {
> foreach (i, child; elements)
> {
> if (child == d)
> {
> elements = remove(elements, i);
> break;
> }
> }
> }
>
> Ugly! :)
>
> It's a direct port from some C# code so don't mind the silly variable names.
A common idiom in various languages for remove is collection.replace(something,
nothing). (This indeed works fine in D for strings :-)
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com