On Friday, 27 January 2017 at 15:39:57 UTC, cym13 wrote:
On Friday, 27 January 2017 at 08:30:41 UTC, Dukc wrote:
[...]
Note that if the set of values to be excluded isn't smaller
than the haystack then using partition is way faster and your
method is the slowest of all. If the order of the array matters
stable partition can be used but is slower than the original
method.
[...]
I forgot to say that the main reason to use partition is that
it's easy to use it to remove the elements of the array in place:
auto r = a.partition!(v => !b.canFind(v));
a.length -= r.length;
It just puts the "bad" elements at the end and changes the length
of the array.