Best data structure for a particle system?

Mikko Ronkainen mikoro at iki.fi
Fri Nov 15 03:52:43 PST 2013


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?


More information about the Digitalmars-d-learn mailing list