title: Swift fill array backwards with reserveCapacity
body: <p>I have a generic algorithm in which an array whose size is known in advance must be filled in <em>reverse</em> (from the highest index to the lowest).  If the array weren't being filled in reverse, the most efficient way to do this would be calling <code>reserveCapacity</code> and then <code>append</code>-ing the values.  In other words,</p>
  
  <pre><code>var arr = [T]()
  arr.reserveCapacity(minimumCapacity: knownCapacity)
  // append values using algorithm
  </code></pre>
  
  <p>However, that will add the first value produced by the algorithm at index <code>0</code>.  I need it to start at index <code>knownCapacity - 1</code> and work backwards.</p>
  
  <p>How could this be accomplished in Swift?  Of course I can add values starting from <code>0</code> and then reverse the array, but reversal is an expensive operation.  Ideally, there would be some sort of <code>reserveBackwardsCapacity</code> and <code>prepend</code> system of methods, or a data structure built specifically for this built into the language, but I haven't been able to find either.</p>
  
  <p>I would use <code>[T](count: knownCapacity, repeatedValue: )</code> and just fill from the back, but because the algorithm is generic (it should work for any type <code>T</code>) I don't have any way of knowing what to put for <code>repeatedValue</code> (and filling the array with values just to be overridden would be expensive and unnecessary).</p>