logoalt Hacker News

Altern4tiveAcctoday at 4:22 PM2 repliesview on HN

Assuming ordering isn't a concern, can't you just have a field called "removed" and skip those when iterating?

Or swap it with the last monster, and keeping an index for the last monster alive.


Replies

tsimionescutoday at 9:09 PM

Sure, but these schemes might have their own drawbacks depending on the exact use case - especially if you have a very dynamic number of monsters and constantly add and remove them (say, some kind of bullet hell style game).

marcosdumaytoday at 4:42 PM

Then you have to read the "removed" field on every field read on every operation.

SoA is only useful when you don't read multiple fields for most operations.

show 1 reply