To make my previous email more concrete (and revise things slightly), deactivating particles would involve: - telling the Model to delete the particle. That removes the pointer in the model and frees the index up to be recycled - the ParticleIterators in the model skip delete particles (skip null pointers) - the particle is marked as invalid and any accesses to it throw exceptions - all pointers to the particle are reference counted and the particle object is deleted when all of them go away
A slightly more complicated alternative which would delay recycling ParticleIndexes would be - marking them as inactive - The Model ParticleInterators skip inactive (and NULL) particles. Python people will just have to deal unless someone knows how to get custom iterators working in python - all pointers held by restraints are reference counted. When all of the pointers held by everything go away, the Particle entry is set to NULL in the model (and can be reused) and the particle is deleted. - the Model maintains a list of free particle indexes and reuses them once they are gone from the system
These proposals leave open the issue of making sure that particle indexes stored in the attribute table always point to the right generation of particle (i.e. make sure that the index doesn't get recycled before they get cleaned up). One solution to this would be to add a new attribute type, that of a particle pointer so these have full reference counted semantics. This would not be hard.