title: Why is swap() sometimes implemented by passing an array?
body: <p>In some comp-sci papers and tests, I see swap() implemented like so:</p>
  
  <pre><code>void swap(int x, int y, int *a)
  {
      int t = a[x];
      a[x] = a[y];
      a[y] = t;
  }
  </code></pre>
  
  <p>Why not simply implement it like so:</p>
  
  <pre><code>void swap(int&amp; x, int&amp; y)
  {
      int t = x;
      x = y;
      y = t;
  }
  </code></pre>
  
  <p>Is the idea to the former to make the calling code cleaner, by not having to index into the array for the first two arguments? I realize it's not a very important question, since we should be using std::swap(), but I'm still curious.</p>