The source project of this merge request has been removed.
Overwrite values to be removed with UINT_MAX and remove them from the array in a separate loop.
Problem reported and solution suggested by @cemeyer in merge request !1 (merged)
I still have to test this code. I'm publishing the merge request to get comments on the approach.