www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13565] New: add AA batch remove using a predicate function

https://issues.dlang.org/show_bug.cgi?id=13565

          Issue ID: 13565
           Summary: add AA batch remove using a predicate function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

To remove multiple AA entries at once we should support calling aa.remove with
a predicate function, taking key and value.

Old code:

Louter: while (true)
{
    Key key;
    foreach (k, v; aa) {
        if (!pred(k, v)) continue;
        aa.remove(k);
        continue Louter;
    }
    break;
}

New code:

aa.remove((k, v) => pred(k, v));

--
Oct 01 2014