Using the mod operator C++
<p>Without using any stls, boosts, and the like I have been trying to rotate the elements in my array. I've been trying to use the mod operator, to be efficient:</p>

<pre><code>void stack::rotate(int r)
{
 r = ( r % maxSize + maxSize ) % maxSize;
 for ( int first_index = 0; first_index &lt; r; ++first_index )
 {
  int mem = items[first_index].n;
  int index = ( first_index + r ) % maxSize, index_prev = first_index;
  while ( index != first_index )
  {
   items[index_prev] = items[index];
   index_prev = index;
   index = ( index + r ) % maxSize;
  }
  items[index_prev].n = mem;
 }
</code></pre>

<p>Where items is an allocated array to an item struct. Although it is a little weird the item struct has an integer 'n' member so that i may use it with integer type varaibles.</p>

<p>But its still not comming out right =( . Im losing the contents of my second element. I think its break time ;)</p>
