On Friday, 15 November 2013 at 11:52:44 UTC, Mikko Ronkainen
wrote:
What would be the best data structure for handling particles in a particle system in D2?

Here's some thoughts:

Particles are simple structs.
Two lists, one for alive particles, one for dead ones.
Memory allocations should be avoided, preallocate everything, no allocations when moving between lists. Keep alive list as short as possible for fast iteration -> move dead particles off during iteration. Removal and addition of single items only, and it should be fast.

Maybe a single-linked list, std.container.SList? Is there any gotchas? Or some better container for this scenario?

Use just one list with a flag in the particle to see whether the
particle is alive or dead, saves swapping between lists and you
can use a simple array for fast access.

Reply via email to