Removing an object from a range

Andrej M. none at none.com
Sun Dec 12 17:43:12 PST 2010


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.



More information about the Digitalmars-d-learn mailing list