In-place filtering of an array

from blog Computer Graphics & Programming with Pekka Väänänen - 30fps.net, | ↗ original
Let’s say you have a bunch of 2D boxes and you want to find only ones that intersect some other box. For example to do collision detection in a game. If you’re in a hurry you can just write a loop and be done with it: