<p>It sounds like you could use <a href="http://en.wikipedia.org/wiki/Multiple_buffering" rel="nofollow">double buffering</a>.  Basically, you'd maintain pointers to two arrays of particle objects &mdash; call them, say, <code>accepted</code> and <code>trial</code>.  At the beginning of a trial, you copy the properties of the particles on the <code>accepted</code> array to those on the <code>trial</code> array, and make any modifications you want.  If the trial is successful, you then just swap the pointers, so that what used to be the <code>trial</code> array becomes <code>accepted</code> and vice versa.</p>

<p>Also, you say that only <em>some</em> of your trials involve costly updates.  If so, you might be interested in techniques like <a href="http://arxiv.org/abs/math.ST/0502099" rel="nofollow">fast variable dragging</a> or <a href="http://arxiv.org/abs/1101.0387" rel="nofollow">ensemble updating</a>.</p>
I need some advice with to find a sufficient algorithm for my simulation
<p>I'm doing a <a href="http://en.wikipedia.org/wiki/Monte_Carlo_method" rel="nofollow">Monte-Carlo simulation</a> of some particles particles. There are several bottle necks in my code but the main one is that in some of the tries I make, I need to update <strong>all</strong> the particles properties. The code is written in c++ and currently I have several loops to achieve that:<br>
1. a loop to store the old properties of all the particles and update the new properties.<br>
2. a 2D loop of interactions.<br>
3. another 2D loop of interactions (I can't combine it with the first one).<br>
4. a loop to store accept the step/a loop to reject the step.  </p>

<p>I am hoping to remove step 4 using swap but I can't find a way to do so. All the particles are a class which has several elements named <code>properties</code> and <code>nextProperties</code> or <code>oldProperties</code>. How would you approach that?</p>