[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-dev] deactivating particles



However, I suggest rather than a single
pointer attribute we use a vector<Particle pointer> attribute. This
would certainly make things like hierarchies much easier to implement
(plus, much faster, since you could just cache a 'child'
ParticleVectorKey rather than having to do a lot of lookups for child1,
child2, child3 etc.) Pointers to single particles are probably
sufficiently unusual that the overhead of a single-element list is
negligible.
I agree that single particles are unusual. However, the overhead entailed by the current model is pretty small so it is not clear to mean having vectors would be noticeably faster. To access a Particle attribute the internal pseudo-code looks something like

check that the vector of child keys is long enough
get the key from the vector
get the particle

If we have a vector it looks like

get the key for the children
get the vector of children
get the particle

so you just save one check which generally succeeds. As a result I would vote for not complicating the interface by having the particle attributes look different from the others. Mostly an aesthetic preference, so not very strong.