3 ms·
If the system starts ordered and is iterated frequently, and things move (due to deletion) rather less than they are iterated, you can use... bubble sort. It's
by samatman 4y ago
If the system starts ordered and is iterated frequently, and things move (due to deletion) rather less than they are iterated, you can use... bubble sort.
It's basically free to do one stripe of bubble sort while iterating, and for games, you'll iterate everything once or more per frame, but introduce and delete things less.
- contravariant 4y agoThe trick there is to ensure things work nicely if different subsets are iterated one after the other. Note that merely ordering isn't quite enough, let's say a particular system needs components ABC and component C is rare, then the ideal situation would be to sort A and B such that those entities with component C are close together.
- samatman 4y agoThe devil is indeed in the details when one sets out to use memory in this Fortran-esque fashion.