Invalid removing using RemoveIf
Brought to you by:
rossjudson
Arrgh ! Removing items from collections is so difficult !
I tried using RemoveIf algorithm and got wrong answer
Items weren't removed at all
After dwelving into code I found a bug
RemoveIf(container,test) calls
RemoveIfIn(start,finish,test) that
in turn call FindIfIn to find first occurence of the
item to delete and then removeCopyIfIn(s, _end, s,
test) to remove remaining items
BUT when you look into removeCopyIfIn you find that
if test(o^) then
begin
_output(dest, o^);
end;
So items that verifies test are copied which is not
expected
behavior !
Solution : add a "not" in front of test(o^) if it does
not break standalone call of removeCopyIfIn
Please forgive my bad english.