This is a followup to pr #24814.
This pr implements the filtering of coins without an additional vector using the remove-erase idiom as discussed in #24814
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
I don't think there is a need to open two conflicting refactoring changes. Please pick the one that you and the reviewers prefer and push it to the existing pull request.