title: Diagonal reflection of an int array
body: <p>I want to perform a diagonal reflection on an int array laid out in a board, reflecting around the diagonal descending from the left to the right. This is an attempt to "flip a chess board around" while working with the <a href="http://en.wikipedia.org/wiki/Eight_queens_puzzle" rel="nofollow">N queens puzzle</a>.</p>
  
  <ul>
  <li>The array is displayed as on a board whose size is <code>n*n</code><br /></li>
  <li>The length of the array is <code>n</code><br /></li>
  <li>The index of the array represents the row (i.e <code>arr[0]</code> means the top row)<br /></li>
  <li>The value at the index represents the horizontal placement of the Queen (i.e <code>arr[2] = 3;</code> would mean "Place a queen at column 4 on row 3" (zero-based index))</li>
  </ul>
  
  <p>Example </p>
  
  <pre><code>int[] matrix = {0,2,4,1,3};
  </code></pre>
  
  <p>would be displayed as</p>
  
  <pre><code>[Q x x x x]
  [x x Q x x]
  [x x x x Q]
  [x Q x x x]
  [x x x Q x]
  </code></pre>
  
  <p>After running the command </p>
  
  <pre><code>matrix = diagonalReflection(matrix);
  </code></pre>
  
  <p>The matrix should look like this (note, the reflection is based on the descending diagonal)</p>
  
  <pre><code>[Q x x x x]
  [x x x Q x]
  [x Q x x x]
  [x x x x Q]
  [x x Q x x]
  </code></pre>
  
  <p>How would I go about to swap the elements accordingly to achieve this result?</p>
  
  <p><strong>Update:</strong><br />
  I have tried problably 5-10 different ways, but this is the one I'm using so far:</p>
  
  <pre><code>public static Board diagonalReflection(Board src){
  
      int n = src.size();
      Board dest = new Board(n);
  
      for (int i = 0; i &lt; n; i++)
          dest.set(src.get(i), i);
  
      return dest;
  }
  </code></pre>
  
  <p>Function note:<br /></p>
  
  <pre><code>Board.get(x) means "return arr[x]"
  Board.set(x, y) means "arr[x] = y"
  </code></pre>