<p><pre><code> for (int R = _rand.Next(); (R & 1) == 1; R >>= 1)
</code></pre>
For C# on .NET, this may work fine, but in general, this is a bad way of extracting a 0/1 choice from a pseudo-random number generator (PRNG). Many PRNGs use linear congruential generators, which are just a multiply and an add, and have highly predictable low bits as a result (frequently just a repeating pattern with a short period, as short as 4 or 8).<p>Safer:<p><pre><code> while (_rand.Next(2) == 0)
</code></pre>
- or even simply reading the bits off the other end.<p>Another nice thing about skip lists is that they are relatively easy to make into cheap persistent structures (aka functional structures), that is, structures where operations return a new immutable copy of the structure, but share most of the substructure with the previous version.