Use std::erase_if to simplify removal of items

This function makes it simpler to remove items from collections. Update
our code to make it more readable.

Bug: 198472780
Test: presubmit

Change-Id: I3bc81bf729e9b22ced16691272187870783c1728
5 files changed